in reply to Chat Error

You'll need to lock the file while you're appending to it. You'll probably want to open the file in append mode to do this, which should tell your OS to be cleverer about going to the end of the file before writing, and then rewind it to the beginning. Here's a brief demo:
use warnings; use strict; use Fcntl ':flock'; our $talkfile="t44.talk"; open(TRANSCRIPT,"+>>$talkfile") or die "Client can't open transcript file: $!"; # Read the file with a shared lock flock(TRANSCRIPT,LOCK_SH) or die "Couldn't lock transcript: $!\n"; seek(TRANSCRIPT,0,0) or die "Couldn't rewind transcript file: $!\n"; print <TRANSCRIPT>; # Write the file with an exclusive lock flock(TRANSCRIPT,LOCK_EX); print TRANSCRIPT "ran at ",time,"\n"; # Unlock the file when you're done flock(TRANSCRIPT,LOCK_UN);

The lock will be released automatically when your program exits, so it's OK to die while holding the lock. Opening the file in append mode will tell perl or the OS to seek to the end of the file before writing anything.