That is because the "Next i" must be after "Next Sht" and not before.