use strict; use warnings; my $output = "output.txt"; die "can't open output file: $!" unless open FH, ">$output"; printf(FH "%s\n", "there won't be any junk characters in this version"); close FH;