open FILE2, "+>file2.txt" or die "Cant not open file2.txt!"; my $line; while($line = readline(ARGV)) { print FILE2 $line; }