Blank.txt at the End of Transmission
Rules of sequential file is : It's saved when its closed, which mean if the file not closed properly, anything written before will not saved, and you'll get blank file.    

so, if you get a blank file while you are sure that the data is received, the only possibility is your program doesn't reach 

myFile.close();   


one of the possibility is the received data not fit into your memory, so the '\n' is undetected.