while (my $line = <$fh_in>) { my $text = $line; chomp ($text); #Strip/remove whitespace between lines of text file; while () { print if (!/^\s*$/); } print $fh_out "$text\n"; #Save stripped results; }