in reply to Modifying lines of text
You don't want to do this inline, unless you can ensure that the lines are exactly the same length, or you will overwrite parts of the next line.
One solution: create a lock file.
do {} until (lock_file()); do_work_in_tmp_file(); copy_tmp_file(); unlock_file();
|
|---|