Changed input to System.in.
Updated while loop.