You have a file with data that you want to process. The amount of data in the file could change. You want to know something about the data set, like its total.
Initialize an accumulator variable. Loop while not EOF (end of file), reading data, and updating the accumulator each time through the loop. See the Explanation of this pattern for a flowchart and code.
An accumulator is a variable that accumulates information about a data set. Here's a flowchart and code that shows how to use an accumulator with a file input loop.