The iteration will be in the middle step (see below).
After initialization, the program loops as long as there is data. When it reaches the end of the data, it writes out the answer and exits.
There are still some details left to specify, such as how the end of data is determined. This might be done with a special sentinel value, or by prompting the user for a "yes" or "no" response. But the over-all design for the program will be the same.
Does this flowchart look familiar?