title: How to avoid buffering on stdin and stdout?
body: <p>When reading from <code>std::io::stdin()</code>, input is buffered until <code>EOF</code> is encountered. I'd like to process lines as they arrive, rather than waiting for everything to be buffered.</p>
  
  <p>Given a shell function <code>bar</code> that runs <code>echo bar</code> every second forever, I'm testing this with <code>bar | thingy</code>. It won't print anything until I <code>^C</code>.</p>
  
  <p>Here's what I'm currently working with:</p>
  
  <pre><code>use std::io;
  use std::io::timer;
  use std::time::Duration;
  
  fn main() {
      let mut reader = io::stdin();
      let interval = Duration::milliseconds(1000);
  
      loop {
          match reader.read_line() {
              Ok(l) =&gt; print!("{}", l),
              Err(_) =&gt; timer::sleep(interval),
          }
      }
  }
  </code></pre>