title: Continue a while loop until EOF (Qt)
body: <p>I'm working on a program to create a list from a large QStringList. So basically after a string match, a while loop will start to add the next strings into a list. This part is working fine. The only problem I have is that the program quits unexpectedly because I don't know how I should add the EOF mechanism.</p>
  
  <p><strong>Update with a more detailed code</strong></p>
  
  <p>Sorry for not providing with enough details about my code. This is how my code looks now. So after the first time the string "PACKAGE TYPE" is detected, I use the function <code>storeLines()</code> function to store the next strings into one of three lists dependent. And this will continue until the next "PACKAGE TYPE" match or EOF. The only thing that is not working correctly now is when the iterator is on the last string of the QStringList. It somehow doesn't detect that the next is <code>inputline.end()</code></p>
  
  <pre><code>void storeLines(QString department, QStringList::iterator current_line, QStringList::iterator endline){
  while(QString::compare(*(current_line + 1),"PACKAGE TYPE") &amp;&amp; (++current_line != endline)){ //this is not working
      if(!QString::compare(department, "MDA")) mda_list.push_back(*current_line);
      else if(!QString::compare(department, "SDA")) sda_list.push_back(*current_line);
      else mix_list.push_back(*current_line);
      }
  }
  
  void void MainWindow::on_pushButton_clicked(){
     QString input = ui-&gt;listinput-&gt;toPlainText().toLatin1();
     QStringList inputline = input.split("\n", QString::SkipEmptyParts );
  
     for(QStringList::iterator pkg_header(inputline.begin()); pkg_header != inputline.end(); ++pkg_header){
         if(!QString::compare(*pkg_header,"PACKAGE TYPE")){
             ++pkg_header;
             if(!QString::compare(*pkg_header,"Department-mda:")) storeLines("MDA", pkg_header, inputline.end());
             else if(!QString::compare(*pkg_header,"Department-sda:")) storeLines("SDA", pkg_header, inputline.end());
             else storeLines("MIX", pkg_header, inputline.end());
         }
      }
  }
  </code></pre>
  
  <p>Thanks in advance!</p>