title: List Iterator getting stuck-Java
body: <p>I have a file which has the following data</p>
  
  <p>1^ I hated that phone it never did what i told it to do it was slow response time s**t net          and would constantly crash out on me as I would load too many apps or videos on to the phone i thought i pods where suppose to be for media driven people. if you don't mind your phone locking up or having to factory reset it every few days go for it.#</p>
  
  <p>2^ This device was the first advanced device that actually had a lot to do on it with so little bugs and the best browser of any smartphone. The I phone 3G and 3Gs innovated the way we make smartphones today.#</p>
  
  <hr>
  
  <p>Each line is delimited with a "#" and in each line it is separated by a "^"
  I am storing them in a listoflists and printing them.
  The code (given below) is printing the 2 lines correctly but gets stuck after that and not exiting. i don't know where the problem is. Please help.</p>
  
  <pre><code>        FileReader fr=new FileReader("comments.csv");
          Scanner sc= new Scanner(fr);
          sc.useDelimiter("#");
  
          ArrayList&lt;ArrayList&lt;String&gt;&gt; listoflists= new ArrayList&lt;ArrayList&lt;String&gt;&gt;();
          ArrayList&lt;String&gt; singlist= new ArrayList&lt;String&gt;();
  
          while(sc.hasNext())
          {
              String line=sc.next();
              String[] element=line.split("\\^");
              for( int i=0; i&lt; element.length;i++)
              {
                  singlist.add(element[i]);
                  bw.write(element[i]);
                  bw.newLine();
                  //System.out.print(element[i]+"\n");
              }
              listoflists.add(singlist);
  
          }
      // it running properly till this part without getting stuck in infinite loop
          ListIterator&lt;String&gt; iter1=singlist.listIterator();
          ListIterator&lt;ArrayList&lt;String&gt;&gt; iter2=listoflists.listIterator();
          while(iter2.hasNext())
          {
              while(iter1.hasNext())
              {
                  System.out.println(iter1.next());
              }
          }
  </code></pre>
  
  <p>Thanks</p>