perl -pe'chomp; END { print "\n" }' file #### open(my $fh_in, '<', $qfn_in) or die("Can't open \"$qfn_in\": $!\n"); open(my $fh_out, '>', $qfn_out) or die("Can't create \"$qfn_out\": $!\n"); while (<$fh_in>) { chomp; print $fh_out $_; } print $fh_out "\n";