while ( $bytesread = read $fh, $buffer, 1024 ) { print "$buffer"; print OUTF $buffer; } close OUTF;