title: porting Python 2 syntax to Python 3
body: <p>I'm trying to run the following code in python3, but it has been written for I'm pretty sure python2:</p>
  
  <pre><code>f = open(filename, 'r')
  self.lines = f.readlines()
  f.close()
  if self.lines[-1] != "\n" :
      self.lines.append("\n")
  </code></pre>
  
  <p>But I'm getting the following error:</p>
  
  <pre><code>  File "randline.py", line 32
      if self.lines[-1] != "\n" :
                                ^
  TabError: inconsistent use of tabs and spaces in indentation
  </code></pre>
  
  <p>Can you help me figure out the correct syntax?</p>