The loop on line 149 relied on the standard variable which threw an error. A local variable has been added to the loop.