write output directly to disk rather than big memory list