gh-119506: fix _io.TextIOWrapper.write() write during flush
#119507
Merged
_io.TextIOWrapper.write() write during flush
#119507