An Iterative Method for Generating Loop Invariants