title: Python: Searching for a RegEx in sys.stdin
body: <p>I have small python script in which I look for a pattern in the standard input, and output it after some reformatting. I have removed the complex pattern and reformatting code from the example.
  Currently my code looks like this.</p>
  
  <pre><code>for line in re.finditer(r"""(.*)\n""", sys.stdin.read(), re.MULTILINE):
      print(line.group(0))
  </code></pre>
  
  <p>Notice the "sys.stdin.read()". This causes the script to buffer the whole input before it looks for a pattern.</p>
  
  <p>How can I pass stdin as a buffer to finditer, so stdin will searched as it is inputted to the script instead of having it buffered first? </p>