Fix an infinite loop due to the accidental re-use of a loop parameter.