title: How do I iterate over all lines of files passed on the command line?
body: <p>I usually do this in Perl:</p>
  
  <p>whatever.pl</p>
  
  <pre><code>while(&lt;&gt;) {
      #do whatever;
  }
  </code></pre>
  
  <p>then <code>cat foo.txt | whatever.pl</code></p>
  
  <p>Now, I want to do this in Python. I tried <code>sys.stdin</code> but I have no idea how to do as I have done in Perl. How can I read the input?</p>