use strict; use warnings; use IO::Handle; open(WRITE, ">>C:\\File\\test.dat"); WRITE->autoflush(1); my $num = 1; while(1) { print "$num\n"; print WRITE "Some new text $num\n"; # using sleep to try and emulate the speed of the actual program sleep 1; $num ++; } close WRITE;