Python 2.7 : Write to file instantly

You can use flush() or you can set the file object to be unbuffered.

Details on using that parameter for open() here.

So you would change your open call to –

outputFile = open("./outputFile.txt", "a", 0)

Leave a Comment