But why are you using a loop over a fixed range instead of a loop from 1 to $end anyway?