title: how to overcome "ValueError: read of closed file" in python 3.5.1
body: <p>I have a python script which fetches the no. of posts, followers and follows from the instagram API. The first time I ran the script, it worked perfect and gave me the required data.
  The script is:--</p>
  
  <pre><code>for r in range(10,12):
      var=r,sheet.cell(row=r,column=2).value
      xy=var[1]
      ij=str(xy)
      myopener=Myopen()
      url=myopener.open('https://api.instagram.com/v1/users/'+ij+'/?access_token=641567093.1fb234f.a0ffbe574e844e1c818145097050cf33')
      beta=json.loads(url)
      item=beta['data']['counts']
      data1.append(item['media'])
      data2.append(item['followed_by'])
      data3.append(item['follows'])
  </code></pre>
  
  <p>I have declared my FancyURLopener as follows:=</p>
  
  <pre><code>class Myopen(FancyURLopener):
  version='Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
  </code></pre>
  
  <p>The second time I ran the script it started showing me this error:-</p>
  
  <pre><code>Traceback (most recent call last):
  File "&lt;pyshell#39&gt;", line 7, in &lt;module&gt;
  beta=json.load(url)
  File "C:\Users\rnair\AppData\Local\Programs\Python\Python35\lib\site-    packages\simplejson-3.8.2-py3.5-win-amd64.egg\simplejson\__init__.py", line 455, in load
  return loads(fp.read(),
  File "C:\Users\rnair\AppData\Local\Programs\Python\Python35\lib\tempfile.py", line 483, in func_wrapper
  return func(*args, **kwargs)
  ValueError: read of closed file
  </code></pre>
  
  <p>How to overcome this? I have been using the same script for a week now and it never gave any error. Why today?</p>