... while(<$fh>) ## this is correct $fh { print $fh2 "$_\n"; ## correct $fh2 } ...