Using nextCharIsWhitespace insetad of nextCharIs(scanner, ' ').