Before you use nextLine()
, you need to check whether there is a next line. You should probably use a regular while()
loop for that reason, rather than a do/while.
Since it's a Scanner and the User may be continuously entering text, you may want to save that text as a String and put a loop outside the while()
checking for the EOF message.