f=open('hoge.txt'.'w')
LOOP = True
While LOOP:
f.write('aaaaa\n')
if satisfied:
LOOP=False
In that case, only 8192 byte files can be created, so
f=open('hoge.txt'.'w',buffering=1)
If you write one line at a time, you can overcome the 8192 wall.