For the following Python code:
fp = open(\'output.txt\', \'wb\') # Very big file, writes a lot of lines, n is a very large number for i in range(1, n): f
If you write line by line, it should not be a problem. You should show the code of what you are doing before the write. For a start you can try to delete objects where not necessary, use fp.flush() etc..
fp.flush()