@yurkad
I guess what Thaddy said is:
you should use 0 as the starting point of index.
When I was a novice programmer, I like to use 1 as the base of index (array, collection, or ...). But I noticed others usually use 0. So I often needed to use my count-1 or index-1 to prevent out of range error when calling or using their functions.
So, I think Thaddy sensed your mistake, which I also think so - the cause of your error is you didn't use the index value properly.