title: Reading a file in reverse over order on python
body: <pre><code>import os.path
  try:
      file1=input("Enter input file: ")
      infile=open(filename1,"r")
      file2=input("Enter output file: ")
      while os.path.isfile(file2):
          file2=input("File Exists! Enter new name for output file: ")
      ofile=open(file2, "w")
      content=infile.read()
      newcontent=content.reverse()
      ofile.write(newcontent)    
  
  except IOError:
      print("Error")
  
  else:
      infile.close()
      ofile.close()
  </code></pre>
  
  <p>Am I on the right track with this code? I can't seem to find a method to reverse the lines in the input file for the output file.</p>
  
  <p>Input ex.</p>
  
  <pre><code>cat dog house animal
  
  plant rose tiger tree
  
  zebra fall winter donkey
  </code></pre>
  
  <p>Output ex.</p>
  
  <pre><code>zebra fall winter donkey
  
  plant rose tiger tree
  
  cat dog house animal
  </code></pre>