# open file in read mode with open(r"E:demosfiles ead_demo.txt", 'r') as fp: for count, line in enumerate(fp): pass print('Total Lines', count + 1)