You make assumptions about how the file is read and where the write seek position is. Mode "r+"
supports write-after-seek, however, you have to explicitly seek to that position.
with open('test.txt','r+') as f:
f.seek(f.tell())
f.write("wow!")
f.flush()
test.txt now contains:
Helwow!orld!
See also Difference between modes a, a+, w, w+, and r+ in built-in open function?