Added missing loop interruption condition.