title: Reading the next line in a text file
body: <p>I'm trying to read input from a text file that will be formatted like this:</p>
  
  <pre><code>2 80 97 
  5 69 79 89 99 58 
  7 60 70 80 90 100 0 59
  </code></pre>
  
  <p>The first number of each line is the number of "grades" per "section."</p>
  
  <p>I got my program to read one section, but I can't figure out how to make it read how many sections there will be, and then read the next line(s).</p>
  
  <p>I think I can put my current code in a count controlled loop that will first read how many sections there are, and run the loop that many times. I just don't know how to convert that idea to code.</p>
  
  <p>Here is the revevant code section:</p>
  
  <pre><code>public static void main(String args[]) throws Exception 
  {
    Scanner in = new Scanner(new File("prog2test.txt")); 
  
    //int sections = (in.nextInt());
    int scores = (in.nextInt());
    int scoresForAverage = scores;
    int scoreTotals = 0;
    double average = 0;
    int A = 0;
    int B = 0;
    int C = 0;
    int D = 0;
    int F = 0;
  
    int highest = 0;
    int lowest = 100;
    while (scores &gt; 0 &amp;&amp; in.hasNextInt())
    {
       int grade = in.nextInt();
       if (grade &gt;= 90)
          A++;
       else if (grade &gt;= 80)
          B++;
       else if (grade &gt;= 70)
          C++;
       else if (grade &gt;= 60)
          D++;
       else
          F++;
  
       if (grade &gt; highest) 
          highest = grade;
       if (grade &lt; lowest)
          lowest = grade;
  
       scores--;
       scoreTotals = (scoreTotals + grade);
     }  
  
    average = scoreTotals/scoresForAverage;
  
    System.out.println("Scores for section 1");
    System.out.println("A's: " + A);
    System.out.println("B's: " + B);
    System.out.println("C's: " + C);
    System.out.println("D's: " + D);
    System.out.println("F's: " + F);
    System.out.println("Lowest score: " + lowest);
    System.out.println("Highest score: " + highest);
    System.out.println("Average: " + average);
  </code></pre>
  
  <p>EDIT: Updated with complete method.</p>