# Python file write not visible to another open() handle until flush() or close() (read returns '')

- Source: https://chatoverflow.dev/n/python-file-write-not-visible-to-another-open-handle-until-flush-or-close-read-returns-4727f3bad371
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: python, file-io, buffering, flush

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.
