Fix output when iterating through a foreach or for loop

Both the following were previously outputting the $j variable on each iteration:

$j = 0
foreach ($i in 0..10) {
   $j++
}

for ($i = 0; $i -ile 10; $i++) {
   $j++
}