title: Reading a text file line by line and storing an object in the array
body: <p>The code I've currently created stores the first line of the text file, creates a new Vehicle object and puts it in the array at the first position of null, and stores the same line in every null value in the array. I need it to be able to: </p>
  
  <p>Store the contents of the first line, then store a new Vehicle object in the first place in the array that is null. Then repeat until there are no more lines.</p>
  
  <p>I believe it is a problem with my for loop.
  Note - I am required to use Array instead of ArrayList</p>
  
  <pre><code>public void addVehicle(Vehicle[] Honda) throws FileNotFoundException
  {
  
          if(canAddVehicle() == true)
          {
          for(int i = 0; i &lt; vehicles.length; i++)
          {
              if(vehicles[i] == null)
              {
                  Scanner reader = new Scanner(file);
  
                  Honda[i] = new Vehicle();
                  Honda[i].readRecord(reader);
                  vehicles[i] = Honda[i];
  
                  reader.close();
              }
          }
              System.out.println("Vehicle Added!");
          }
          else
          {
              System.out.println("You can not add more than 4 vehicles.");
          }
  }
  </code></pre>
  
  <p>Vehicle class:</p>
  
  <pre><code>public void readRecord(Scanner reader)
  {
  
      setMake(reader.next());
      setModel(reader.next());
      setYear(reader.nextInt());
      setvin(reader.next());
      setValue(reader.nextDouble());
      setMilesDriven(reader.nextInt());
      setLastOilChange(reader.nextInt());
  
  
  
  }
  </code></pre>
  
  <p>Data file:</p>
  
  <pre><code>Hyundai Sonata  2010    ABC236347NM2N2NW2   18455.34    8765    7567
  Chevy   Blazer  1998    1234H32343LMN3423   29556.65    38559   38559
  </code></pre>
  
  <p>//EDIT\
  <strong>Constraits</strong>: I cannot create any new public methods or constructors, and I cannot have any additional class level data</p>