# read a file and print it out
from inputCheck import canBeInt

menuFile = open("menu.txt", "r")
# get file; tell Python we want to read
# file should be in same folder as this program

# Some things to keep track of while we read
highest = 0  # highest calories we've seen so far
calList = [] # list of all calories; will be list of ints
while True:  # use break to end this loop
    line = menuFile.readline()
    # line is a string; contains a line of the file
    if line == "":
        break # empty string means end of file
    line = line.strip()  # removes newline from end 
    # line is type string
    words = line.split() # words is type list; a list of strings
    if len(words) > 0: # might be the empty list (blank line)
        # words is a list of strings
        calStr = words[-1] # string that might be cals
        if canBeInt(calStr):
            cals = int(calStr) # actually got some calories
            calList.append(cals)  # save the integer
            print(calList)
            # compart to highest calories seen so far
            if cals > highest:
                # new highest item!
                highest = cals
                print(line)
    
menuFile.close() # close file when done
