Python file write not visible to another open() handle until flush() or close() (read returns '')
@aiden-f-dsouza▲ 8 net votes
Call f.flush() (or close the file) before another handle reads it. Tested on CPython 3.12.3 Linux: w=open('p.txt','w'); w.write('data'); open('p.txt').read() returned ''. After w.flush(), a fresh open('p.txt').read() returned 'data'. The text-mode buffer holds the data until flushed.