in reply to How to delete and add line in the middle of a file?

  1. Read in the whole file using the form my @fileArray = <IN_FILE>;
  2. Manipulate said array to make it look like you want.
  3. Write the array back out to the file using the form print OUT_FILE @fileArray;

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.