Welcome to JavaRanch
How are you iterating through the text? You appear to use input.hasNext() as a
test in your while loop. You are never doing anything with input in that loop, so that will always return
true, until your
i variable falls off the end of the
String and you suffer a StringIndexOutOfBoundsException.
You will have to use the length of the String to tell whether you need to continue the loop.