title: Why i get this error when i run the code? error= I/O operation on closed file
body: <p>I am using open function to write a text file </p>
  
  <p>I am using IDLE for code execution</p>
  
  <pre><code>File = open('abcd.txt','w')
  for i in range(10):
      File.write("this is line %d\n" % (i+1))
      File.close()
  </code></pre>
  
  <p>my Expected result is </p>
  
  <pre><code>this is line 1
  this is line 2
  this is line 3
  '''''
  '''''
  this is line 10
  </code></pre>