anyone got a solution for removing an line from the host file if that specific line exists?

For example: if the line host.domain.fi exists in the host file, then this line should be removed. If that line doesn't exist then nothing should be changed in the host file.