title: write to file within a for loop - python
body: <p>I am trying to iterate over JSON and write to a file as the information is retrieved. My code looks like this</p>
  
  <pre><code>for i in range(100):
      identifier = data ['items'][i]['id']
      out_file.write(identifier)
  </code></pre>
  
  <p>When I run it I get an indent error on the out_file.write line. I have seen so much code formatted in this way and I'm baffled as to why it isn't working for me. If I make the out_file line even with the for line, the program works, but only writes the last identifier in the loop. Any advice?</p>