title: Python read() doesn't read the file
body: <p>So I made a simple script in Python which takes a filename as a command line argument and reads the given file whenever the script is executed. Pretty straight forward, whenever I execute the script it does not print the text inside the file, nor do I get an error. I am pretty new to programming and have been breaking my head for hours in this piece of code.</p>
  
  <pre><code>import sys
  
  def openfile(filename):
      f = open(filename, mode='r')
      f.read()
      f.close()
  
  if __name__ == '__main__':
          openfile(filename = sys.argv[1])
          print('script has been executed')
  </code></pre>
  
  <p><strong>Quick disclaimer</strong> I know someone posted a similar question a few years ago, but he did not get a direct answer on why his code wasn't working and I did not get the information I was looking out for the answers.
  Also sorry for my poor English. I did my best to keep it clear, but English is not my first language.</p>