in reply to File contents not updated properly

Using IO::Handle, We can flush the data whenever we need.
Like below :
use IO::Handle;
open(FH,">Sample");
while(1) {
print FH "This is for testing\n";
FH->flush();
sleep 1;
}