Of course, the program could be written with just one for loop, and with no array, but retaining data in an array makes it easy to perform a variety of computations without rereading the file.
for