How to delete line in file

How is it possible to delete a determinated line?
For example, I have this file:

line1
line2
line3
line4

And I want to delete line3, and the file will be:

line1
line2
line4
You have to read in each line in the file, and then write every line back, but skip the line that you want to remove.

In other words, you can't simply remove a particular line, you have to write the entire file again.
Last edited on
thanks.
Topic archived. No new replies allowed.