''' linereader.py Jeff Ondich, 2013-01-04 Updated for Python 3, 2019-01-04 Reads lines from a file, prints them in upper-case, and prints a count of the lines at the end. Intended as the Python half of parallel examples in Python and Java. See LineReader.java. ''' input_file_path = 'somelines.txt' try: input_file = open(input_file_path) except Exception as e: print('Cannot open {0}'.format(input_file_path), file=sys.stderr) exit() number_of_lines = 0 for line in input_file: print(line.upper(), end='') number_of_lines += 1 print('\nNumber of lines: {0}'.format(number_of_lines))