# At this point I have created some sort of lock to ensure # nobody else is going to read or write $infile_name while () { # Using read instead of would be more efficient print TEMPFILE; } close TEMPFILE rename $temp_filename, $infile_name or die # Remove the lock here