Use a generator process to write file