title: OSError: [Errno 22] Invalid argument:
body: <p>I'm scraping a lot of reviews from a site with Python, for each review I call the "review" function and then open the file and append it to it. It works for a while but then the following error appears me everytime and not it the same review.</p>
  
  <blockquote>
    <p>OSError: [Errno 22] Invalid argument</p>
  </blockquote>
  
  <p>I tried json.dumps:</p>
  
  <pre><code>scraped_data = reviews(line)
  with open('reviews','a' ) as f:
      f.write(json.dumps(scraped_data,f,indent = 4))
  </code></pre>
  
  <p>but the same error keeps appearing. I also tried json.dump:</p>
  
  <pre><code>scraped_data = reviews(line)
  with open('reviews','a' ) as f:
      json.dump(scraped_data,f,indent = 4))
  </code></pre>
  
  <p>and, for some reason, I tried without indent too.</p>
  
  <p>edit: full traceback for json.dumps:</p>
  
  <pre><code>Traceback (most recent call last):
  File "s.py", line 202, in &lt;module&gt;
  with open('reviews','a' ) as f:
  OSError: [Errno 22] Invalid argument: 'reviews' 
  </code></pre>
  
  <p>full traceback for json.dump:</p>
  
  <pre><code>Traceback (most recent call last):
  File "s.py", line 203, in &lt;module&gt;
  json.dump(scraped_data,f,indent = 4)
  OSError: [Errno 22] Invalid argument: 'reviews'
  </code></pre>