In the compound statement governed by a loop condition, you should do something that will eventually make the condition evaluate to false. In that particular loop, for instance, you might actually read from the file instead of repeating the same calculation over and over.