my $flock = 1 open (FILE1, "file_to_copy.ext") or die "Can't open for reading: $!"; open (FILE2, ">file_to_create.ext") or die "Can't open for writing: $!"; binmode FILE1; if ($flock == 1) { flock (FILE2, 2); } binmode FILE2; while ( read(FILE1,$file_contents,1024) ) { print FILE2 $file_contents; } close (FILE1); if ($flock == 1) { flock (FILE2, 8); } #this is in fact not needed, thanx to crazyinsomniac for pointing out the insignificance ... read "file locking" for more information close (FILE2);