You could use System.out.println() to make sure you are reading what you expect and assigning that input to whatever you mean to assign it to.



while(infile.hasNext())
{
...