use strict; use warnings; my $rowcount = 0; open (FH, ">> 667868.txt") || die "Can't open 667868.txt $!"; while() { print $_; # it is working print FH $_; # not appending $rowcount++; # here it is counting } close FH; print $rowcount; __DATA__ now is the time for all good men to come to the aid of their country, while the quick red fox jumps over the lazy brown dog's back.