title: Ruby - STDIN.read
body: <p>I'm trying to read from a file, and because my more complex code doesn't work, I came back to basics to see whether it even reads properly.
  My code:</p>
  
  <pre><code>   MyParser.new(STDIN.read).run.lines.each do |line|
       p line.chomp
     end
  </code></pre>
  
  <p>I use</p>
  
  <pre><code>ruby program
  </code></pre>
  
  <p>(it's placed in a <code>bin</code> directory and I saved it without <code>.rb</code> )</p>
  
  <p>Now program is waiting for me to write something. I type:</p>
  
  <pre><code>../examples/file.txt
  </code></pre>
  
  <p>and use <code>CTRL + Z</code> (I'm on Windows 10). It produces <code>^Z</code> and I hit enter.
  Now I have an error:</p>
  
  <pre><code>Invalid argument @ rb_sysopen - ../examples/file.txt (Errno::EINVAL)
  </code></pre>
  
  <p><code>MyParser</code> class and its whole logic works fine. I'll be grateful for any hints.</p>