# Joe Schmoe
#
# Program:     filesCh5.py
# Description: Read data from a file and store the average in a different file
# Input:       Three integer grades, one per line, in the file "scores.txt"
# Output:      The floating point average of the grades in the file "average.txt"

def main ():
    infile = open ("scores.txt", "r")

    print ("Reading file...")
    score1 = eval (infile.readline())
    score2 = eval(infile.readline())
    score3 = eval(infile.readline())
    average = (score1 + score2 + score3) / 3.0
    print ("Average is:", average)
        
    outfile = open ("average.txt", "w")
    print ("Average is:", average, file=outfile)
    
    infile.close()
    outfile.close()
main()
    
