title: Errno::EINVAL: Invalid argument @ io_write
body: <p>I have a piece of Ruby code that grabs a zip file from S3 and saves it locally.</p>
  
  <pre><code>File.open(local_filename, 'wb') { |file| file.write(body) }
  </code></pre>
  
  <p>This code works on some files but not others.</p>
  
  <p>For the ones that don't work I get this error:</p>
  
  <blockquote>
    <p>Errno::EINVAL: Invalid argument @ io_write - /path/to/file.zip</p>
  </blockquote>
  
  <p>What could be the reason for this?</p>