# Program to print file contents # Matt Bishop, Feb 14, 2012 # for ECS 10 Winter 2012 # def main(): # get file name try: fname = input("Please enter the name of the file to print: ") except EOFError: return except: print("Could not read what you typed") return # # print file contents # # open the file try: infile = open(fname, 'r') except IOError: print("Error opening file", fname, "for reading") return except: print("Unknown error") return # read and print the contents content = infile.read() print(content) # clean up infile.close() main()