Then maybe you should look at your loop construct.
for(i=0;i<9;i++)
How many times do you think this loop will execute? (Hint it is not 10).

Jim