title: File not found with Python's fileinput
body: <p>Given the following code:</p>
  
  <pre><code># Edit build number in test report
  print(path)  # TODO remove
  html_report = fileinput.input(path, inplace=True)
  for line in html_report:
      print(line.replace('$BUILD_NUMBER',
                         args.number).rstrip())
  html_report.close()
  </code></pre>
  
  <p>I get the following output:</p>
  
  <pre><code>/home/jenkins/workspace/reports/report201610261053.html
  Traceback (most recent call last):
    File "report_generator.py", line 58, in &lt;module&gt;
      for line in html_report:
    File "/usr/lib/python2.7/fileinput.py", line 252, in next
      line = self.readline()
    File "/usr/lib/python2.7/fileinput.py", line 321, in readline
      os.rename(self._filename, self._backupfilename)
  OSError: [Errno 2] No such file or directory
  </code></pre>
  
  <p>If I just use the command:</p>
  
  <pre><code>gedit /home/jenkins/workspace/reports/report201610261053.html
  </code></pre>
  
  <p>I can check that the file exists. In fact, if it didn't I would expect this error to be raised in the <code>fileinput.input()</code> line, not in the line loop.</p>
  
  <p>Any idea of what's wrong?</p>