in reply to Perl Script New Line problem

Are you serious?

If this part of the code doesn't print a newline

print $out_fh $line ; #No need to chomp - we print the "\n"

Maybe $line contains no newline, maybe you need to print one

Say

$line =~ s/\s+$//; $line = "$line\n";