Python Global File
<p>How can I write to a global file inside of a function?</p>

<p>Example:</p>

<pre><code>output_file=open("output_file_name.txt", "w")

def write_to_file:    
    global output_file    
    output_file.write('something')

write_to_file()

output_file.close()
</code></pre>

<p>The code above is not working. It says "ValueError: I/O operation on closed file" 
Any ideas?</p>
