writing to file object, python
<p>I have the following code</p>

<pre><code>for i in np.arange(10):
   f = open("file_"+str(i)+".dat",'w')
   for j in np.arange(100):
      f.write(str(func(i,j)))
      f.write("\n")
      print func(i,j)
   f.close()
</code></pre>

<p>Now, I can see the output on the terminal because of the <code>print</code> command but the files that it is creating are empty. It isn't able to write the output to the file. How can I do it?</p>
