Getting weird behavior in if statement.

You MAY NOT store a value in results[5], but the damage is already done by the time you check if (i>4).