my $original_size = -s $target_full_path; # how many bytes in the file open( my $out, ">>", $target_full_path) # I like using lexical file handles, and or die "Can't open $target_full_path: $!"; # reporting system error messages while($fetchdata=$sth4->fetchrow_array()) { print $fetchdata; print $out $fetchdata or die "print to file failed: $!"; $rowcount++; } close $out or die "Unable to close output file: $!"; print $rowcount; my $current_size = -s $target_full_path; # how many bytes now printf( "File %s was %d bytes, is now %d bytes\n", $target_full_path, $original_size, $current_size );