When executing the following code, after the second read, file gets filled with zero until being 4096 bytes large. I can\'t figure out why :
f = open(\"file.
Best way to solve your problem: don't mix read() and write().
read()
write()
Otherwise: after the write(), use seek() before the second read() to read your file from the beginning:
seek()
f = open("file.txt", "w+") print f.read() # prints '' f.write("Hello") f.seek(0) print f.read() # print 'Hello' f.close()