title: Don't know what is causing error in Java code
body: <p>I keep getting an error and I am unsure why. This is my code</p>
  
  <pre><code>public class test {
      public static void main(String[] args) throws FileNotFoundException {
  
          Scanner inscan = new Scanner(System.in);
          System.out.print("Enter input file name: ");
          String inputfilename = inscan.nextLine();
  
          File inputfile = new File(inputfilename);
          Scanner in = new Scanner(inputfile);
          String inputline = in.nextLine();
  
          ArrayList&lt;String&gt; Names = new ArrayList&lt;String&gt;();
  
          in.nextLine();
          in.nextLine();
  
          int total = 0;
  
          while(in.hasNextLine()){
              in.nextInt();
              String Mname = in.next();
              int Number = in.nextInt();
              Names.add(Mname);
              total += Number; 
         }
         in.close();
  
         for (String Mname : Names) {
             System.out.println(Mname);
         }
         System.out.println("total number is " + total);
      }
  }
  </code></pre>
  
  <p>Prints:</p>
  
  <pre><code>hi
  total number is 38
  </code></pre>
  
  <p>This is what the text file looks like.</p>
  
  <pre><code>test
  test
  1   mike 34
  2   hi 38
  </code></pre>
  
  <p>I am first skipping the first two lines. Then getting all the names. Then printing the total number of all those names. It is now working with no errors but only prints one thing. </p>