title: getNext() Linked List
body: <p>I'm really new to Java and StackOverflow so please don't be mean. I would really appreciate some help. Thank you in advanced.</p>
  
  <p>I feel like this is really easy and I've already tried this out a million different ways but it's not working. </p>
  
  <p>I am trying to take in a text file and store it into a linked list and I'm trying to access the third node of this linked list. For some reason, I can access the first node, then I can use the getNext() command to go to the next node, but when I try to use getNext() to go the third node, it continues to return the second node. So it is not going to third node. 
  Am I just missing some key concept? Also let me know if you need anymore information. </p>
  
  <p>The text file that is being taken in is:
  5 
  A B C D E 
  A B //This is the line that I want
  B C
  B D
  C D
  C E
  D E</p>
  
  <p>Here is part of my code: </p>
  
  <pre><code>public static void main(String[] args) throws IOException{
      /**
       * Check whether the user types the command correctly
       */
      if (args.length != 1)
      {
  
          System.out.println("Invalid input");
          System.out.println(args.length);
          System.exit(1);
      }
  
      String filename = args[0];
      Scanner input = new Scanner (new File(filename));
  
              LinkedList&lt;String&gt; linkedList= new LinkedList&lt;String&gt;();
  
              while(input.hasNext())
      {
          linkedList.addToRear(input.nextLine());
      }
  
              LinearNode&lt;String&gt; link= linkedList.firstLink;
  
              String temp = " ";
      link.getNext();
      temp = (String)link.getElement();
      String[] numofVerticesArray = temp.split(" ");
      int numOfVertices = Integer.parseInt(numofVerticesArray[0]);
      int lineNumber = 1;
  
      String [] arrayOfVertices; 
      LinearNode&lt;String&gt; secondLine = link;
      String temp2;
  
  
      for (int i=0; i &lt;= lineNumber; i++)
      {
          secondLine = link.getNext();
      }
      lineNumber = 2;
      temp2 = (String)secondLine.getElement();
      arrayOfVertices = temp2.split(" ");
  
              int[][] adjMatrix = new int[numOfVertices][numOfVertices];
  
      LinearNode&lt;String&gt; edgeLine = link;
      String [] arrayOfEdge;
      int rowCount = 0;
      int columnCount = 0;
      String temp3;
      lineNumber = 2;
  
      for (int i=0; i &lt;= lineNumber; i++)
      {
          edgeLine = link.getNext();
          System.out.print((String)edgeLine.getElement());
                      //When this is printed out, the second node's 
                      //content is printed out, not the third node
      }
      lineNumber++;
      temp3 = (String)edgeLine.getElement();
      arrayOfEdge = temp3.split(" ");
  </code></pre>