title: Problem with reading multi extension .fits files
body: <p>I am trying to read/open some multi-extension .fits files. But I have a problem opening them. Here is the part of the cod I am using to open .fits files located in the same folder:</p>
  <pre><code>imgs = sorted(glob.glob('location_of_the_files/*.fits'))
  
  
  for location in imgs:   
      hdul = fits.open(imgs) 
      original = hdul[1].data
      model = hdul[2].data
      residual = hdul[3].data
  </code></pre>
  <p>When running this I am getting this:</p>
  <pre><code>OSError: File-like object does not have a 'write' method, required for mode 'ostream'.
  </code></pre>
  <p>I try to check on the internet, but I do not understand what is going on.
  Any help on how to solve this?</p>
  <p>Maybe it is important to mention when trying to open single .fits file with this code everything works without any problem:</p>
  <pre><code>hdul = fits.open(&quot;location_of_the_files/image_data.fits&quot;)
  
  original = hdul[1].data 
  model = hdul[2].data
  residual = hdul[3].data
  
  </code></pre>
  <p>If needed let me know and I can upload .fits files (in that case, please just tell me how to do this here).</p>
  <p>Thanks.</p>