in reply to to delete a set of specific lines in a file

That's because you slurp the entire file into memory. It's better to step through the file line-by-line. It is more scalable and gives a better performance.

  • Comment on Re: to delete a set of specific lines in a file