title: Read a File from redirected stdin with python
body: <p>I am trying to read the content of a text file that was redirected stdin via the command line, and send it by the Internet when the receiver has to assemble it back to it's original form.</p>
  
  <p>For instance:</p>
  
  <pre><code>$ python test.py &lt; file.txt
  </code></pre>
  
  <p>I have tried to read the file and to assemble it back with the following code inspired by <a href="https://stackoverflow.com/questions/9589092/read-input-from-redirected-stdin-with-python">link</a>:</p>
  
  <pre><code>for line in sys.stdin:
    stripped = line.strip()
    if not stripped: break
    result = result + stripped
  
  print "File is beeing copied"
  file = open("testResult.txt", "w")
  file.write(result)
  file.close()
  print "File copying is complete!"
  </code></pre>
  
  <p>But this solution works as long as I DON'T have an empty row( two '\n' one after another) in my file,if i do have, my loop breaks and the File reading ends.How can I read from stdin till i reach &lt;> of the file that was redirected? </p>