title: How to remove trailing whitespace in code, using another script?
body: <p>Something like:</p>
  
  <pre><code>import fileinput
  
  for lines in fileinput.FileInput("test.txt", inplace=1):
      lines = lines.strip()
      if lines == '': continue
      print lines
  </code></pre>
  
  <p>But nothing is being printed on stdout.</p>
  
  <p>Assuming some string named <code>foo</code>:</p>
  
  <pre><code>foo.lstrip() # to remove leading white space
  foo.rstrip() # to remove trailing whitespace
  foo.strip()  # to remove both lead and trailing whitespace
  </code></pre>