my best guess is that the reason for this difference in length is because:
when you output the whole string then Kerning is applied to your string, so the length of string WITH Kerning applied is LESS than sum of the individual characters.
when you draw char by char, then NO KERNING is applied, and rendered string is just sum of the lengths of individual characters.
The simpliest thing for you to do, is to make your own function called textNoKerning(String, float, float) which will just print character by character, and thus your strings will be compliant.
Other solution is based on determening length's of words with textWidth() and avoid operating on the level of individual characters.