title: Image from URL Code Ruby
body: <p>I'm making a random cat picture cracker, and decided that Ruby was the best. This code,</p>
  
  <pre class="lang-rb prettyprint-override"><code>require 'chunky_png'
  require 'open-uri'
  
  d=rand(2000)+1
  
  url="http://www.placekitten.com/"
  open('image.png', 'wb') do |file|
    file &lt;&lt; open(url,d).read
  end
  </code></pre>
  
  <p>This is probably a really easy fix, but I'm new to ruby.... I get this error when I run it</p>
  
  <blockquote>
    <blockquote>
      <p>C:/Ruby200/lib/ruby/2.0.0/open-uri.rb:146:in <code>open_uri': invalid access mode 200
      (URI::HTTP resource is read only.) (ArgumentError)
              from C:/Ruby200/lib/ruby/2.0.0/open-uri.rb:688:in</code>open'
              from C:/Ruby200/lib/ruby/2.0.0/open-uri.rb:34:in <code>open'
              from Kittens.rb:8:in</code>block in '
              from C:/Ruby200/lib/ruby/2.0.0/open-uri.rb:36:in <code>open'
              from C:/Ruby200/lib/ruby/2.0.0/open-uri.rb:36:in</code>open'
              from Kittens.rb:7:in `'</p>
    </blockquote>
  </blockquote>