in reply to File Input and Output

i am running this code to create a new file.But i am simply getting a blank file after runing this code .I am using Ctrl+Z to terminate writing.I hope i m missing something .Can anyone point out my mistake ?
open FILE, ">keylogger.dat";
print FILE $_;
close FILE;