title: Problems with reading and writing a text file in Python
body: <p><strong>This answer was solved by doing <code>print (file.read())</code></strong></p>
  
  <p>I have a project called 'PyDOS'. I recently discovered that you can read and write files in Python, I implemented this and the writing bit worked. But when trying the read part, it gives a syntax. The code that's messing up the reading part is:</p>
  
  <pre><code>print file.read
  </code></pre>
  
  <p>This is the code with the first error:</p>
  
  <pre><code>def textviewer():
     print ("Text Viewer.")
     file_name = input("Enter a text file to view: ")
     file = open(file_name, "r")
     print file.read #This returns 'Syntax Error' when pressing F5
     input("Press enter to close")
  
  def edit(): #However, the writing function works just fine.
          os.system('cls' if os.name == 'nt' else 'clear')
          print ("EDIT")
          print ("-------------")
          print ("Note: Naming this current document the same as a different document will replace the other document with this one.")
          filename = input("Plese enter a file name.")
          file = open(filename, "w")
          print ("Now, Write 5 lines.")
          line1 = input()
          line2 = input()
          line3 = input()
          file.write(line1)
          file.write("\n")
          file.write(line2)
          file.write("\n")
          file.write(line3)
          file.close()
          print ("File saved!")
          time.sleep(3)
  </code></pre>
  
  <p>It returns syntax error, I tried <code>file.read()</code> but instead showed:</p>
  
  <pre><code>&lt;built-in method read of _io.TextIOWrapper object at 0x10ada08&gt;
  </code></pre>