I would alter the condition of the while loop for this:


while (the string is not empty)


in combination with a different scanner method...