Alternative content
#Write into outfile -- collision free because of multicore usesage
sub collision_free_write {
my($outFile, $msg) = @_;
open my $ofh, ">>", $outFile or die "$0 [$$]: open: $!";
flock $ofh, LOCK_EX or die "$0 [$$]: flock: $!";
print $ofh "$msg\n" or die "$0 [$$]: write: $!";
close $ofh or warn "$0 [$$]: close: $!";
}