title: Why is this code not running after my While loop in class constructor
body: <p>Code following the <code>while (mysc.hasNextLine())</code> is not running which leads to an error as arrays are not populated with data.</p>
  <pre><code>        try {
              File collectorFile = new File(&quot;items.csv&quot;);
              Scanner mysc = new Scanner(collectorFile);
              int count = 0;
              int count2 = 0;
              int position = 0;
              String[] records = new String[24];
              while (mysc.hasNextLine()) {
                  
                  String record = mysc.nextLine();
                  records[count] = record;
                  System.out.println(records[count]);
                  count++;
                  
              }
              System.out.println(&quot;hello thyere&quot;);
              for(String i : records) {
                  String[] parts = i.split(&quot;,&quot;);
                  if (count2 &lt; 5) {
                      System.out.println(&quot;position:&quot; + position + &quot;count:&quot; + count2);
                      Item test = new Item(Double.parseDouble(parts[0]), Integer.parseInt(parts[1]), parts[2],
                              Integer.parseInt(parts[3]));
                      a[position] = test;
                  }
                  if (count2 &gt;= 5 &amp;&amp; count &lt;10) {
                      Item test = new Item(Double.parseDouble(parts[0]), Integer.parseInt(parts[1]), parts[2],
                              Integer.parseInt(parts[3]));
                      b[position] = test;
                  }
                  if (count2 &gt;= 10 &amp;&amp; count &lt;15) {
                      Item test = new Item(Double.parseDouble(parts[0]), Integer.parseInt(parts[1]), parts[2],
                              Integer.parseInt(parts[3]));
                      c[position] = test;
                  }
                  if (count2 &gt;= 15 &amp;&amp; count &lt;20) {
                      Item test = new Item(Double.parseDouble(parts[0]), Integer.parseInt(parts[1]), parts[2],
                              Integer.parseInt(parts[3]));
                      d[position] = test;
                  }
                  if (count2 &gt;= 20 &amp;&amp; count &lt;25) {
                      Item test = new Item(Double.parseDouble(parts[0]), Integer.parseInt(parts[1]), parts[2],
                              Integer.parseInt(parts[3]));
                      e[position] = test;
                  }
                  
                  count2++;
                  if (position == 4) {
                      position = 0;
                  }
              }
  </code></pre>
  <p>The output is</p>
  <pre><code>80,20,Walkers Ready Salted,0
  80,20,Walkers Cheese and Onion,0
  80,20,Walkers Cheese and Onion,0
  80,20,Walkers Prawn Cocktail,0
  80,20,Walkers Prawn Cocktail,0
  80,20,Mars Bar,0
  80,20,Mars Bar,0
  80,20,CurlyWurly,0
  80,20,CurlyWurly,0
  80,20,Snickers Bar,0
  80,20,Snickers Bar,0
  80,20,Daim Bar,0
  80,20,Daim Bar,0
  80,20,Tayto Cheese and Onion,0
  80,20,Tayto Cheese and Onion,0
  80,20,Bounty bar,0
  80,20,Tayto Salt and Vinegar,0
  80,20,Tayto Salt and Vinegar,0
  80,20,Tayto Prawn Cocktail,0
  80,20,Tayto Prawn Cocktail,0
  80,20,Haribo Star mix,0
  80,20,Haribo Star mix,0
  80,20,Haribo Tangfastics,0
  </code></pre>
  <p>The <code>System.out.println(&quot;hello thyere&quot;);</code> is never reached.</p>