Q:

Python: Printing Running Total and Values after Loop

I am having trouble printing running totals and "averageRaise" value at the end.  It looks like when a new line is being read from the input file, it prints my four statements that I want printed at the end of the output.  Below is the text file, program code, and a part of the output to see the pattern:
Program Code:
def main():

inFile = open('Program7.txt', 'r')

memberNumber = 1
totalRaise = 0
payTotal = 0
newPayTotal = 0

lineRead = inFile.readline()
while lineRead ! = '':
    words = lineRead.split()
    for word in words:
        pay = float(word)

        if pay > float(60000):
            newPay = pay * 1.04
        elif pay > float(50000):
            newPay = pay * 1.07
        else:
            newPay = pay * 1.055

        payRaise = newPay - pay
        print('Pay raise for faculty member #' + str(memberNumber) + ': ' + '$' + str(format(payRaise, ',.2f')))

        memberNumber += 1
        totalRaise += float(payRaise)
        payTotal += pay
        newPayTotal += newPay
        averageRaise = totalRaise / (memberNumber - 1)

    print('The total amount of raises is: $' + str(format(totalRaise, ',.2f')))
    print('The average of all the raises is: $' + str(format(averageRaise, ',.2f')))
    print('Total amount of faculty pay without raise: $' + str(format(payTotal, ',.2f')))
    print('Total amount of faculty pay with raise: $' + str(format(newPayTotal, ',.2f')))

    lineRead = inFile.readline()

# Close the file. 
inFile.close()

# Call the main function. 
main()

Input File:
52500.00       64029.50      56000.00      50001.00
65500.00       42800.00      45000.50      68900.00
60000.00       59999.94      54120.25      64100.00
44000.50       80100.20      90000.00      41000.00
60500.50       72000.00      50000.01      50000.00
80001.75       60001.00

First part of Output:
Pay raise for faculty member #1: $3,675.00
Pay raise for faculty member #2: $2,561.18
Pay raise for faculty member #3: $3,920.00
Pay raise for faculty member #4: $3,500.07
The total amount of raises is: $13,656.25
The average of all the raises is: $3,414.06
Total amount of faculty pay without raise: $222,530.50
Total amount of faculty pay with raise: $236,186.75
Pay raise for faculty member #5: $2,620.00
Pay raise for faculty member #6: $2,354.00
Pay raise for faculty member #7: $2,475.03
Pay raise for faculty member #8: $2,756.00
The total amount of raises is: $23,861.28
The average of all the raises is: $2,982.66
Total amount of faculty pay without raise: $444,731.00
Total amount of faculty pay with raise: $468,592.28
Pay raise for faculty member #9: $4,200.00
Pay raise for faculty member #10: $4,200.00
Pay raise for faculty member #11: $3,788.42
Pay raise for faculty member #12: $2,564.00
The total amount of raises is: $38,613.69
The average of all the raises is: $3,217.81
Total amount of faculty pay without raise: $682,951.19
Total amount of faculty pay with raise: $721,564.88

A:

Look at the indentation level of your 4 last print statements.  They get executed once per line, since they're inside the loop that is performed once per line.  Move them to the outside of your loop and you should get what you want:
lineRead = inFile.readline()
# start of the loops which executes once per line
while lineRead ! = '': 
    words = lineRead.split()  

    # rest of your code here . . . 

    lineRead = inFile.readline() 

print('The total amount of raises is: $' + str(format(totalRaise, ',.2f'))) 
print('The average of all the raises is: $' + str(format(averageRaise, ',.2f'))) 
print('Total amount of faculty pay without raise: $' + str(format(payTotal, ',.2f'))) 
print('Total amount of faculty pay with raise: $' + str(format(newPayTotal, ',.2f')))

