I found the problem... I forgot to increment the i. Damn how stupid I am..