title: Do-while infinite loop in Qt
body: <p>I'm trying to read in a file of trace addresses (each on their own line) and append to the front of each. This input file is intended to be the engine of a cache emulator i'm trying to build. I am having issues reading the file in without getting into an infinite loop. When I change the do-while to run on a false condition, I get the proper output for just the do segment. Therefore, I know I'm running into an infinite loop issue with how I worded my while segment. Maybe i'm fatigued and can't see the issue with this function: </p>
  
  <pre><code>void MainWindow::readFile(){
      infoLabel-&gt;setText(tr("Invoked &lt;b&gt;File|Open&lt;/b&gt;"));
      QString filename="trace.txt";
      QString path = QDir::currentPath();
      QFile file("//Users//nathan1324//Desktop//trace.txt");
      //file.open(QIODevice::ReadOnly);
      if(!file.exists()){
          qDebug() &lt;&lt; "File cannot be found "&lt;&lt;filename;
          qDebug() &lt;&lt; " " &lt;&lt; path;
      }else{
          qDebug() &lt;&lt; filename&lt;&lt;" Opening...";
      }
      QString line;
      textEdit-&gt;clear();
      if (file.open(QIODevice::ReadOnly | QIODevice::Text)){
          QTextStream stream(&amp;file);
          do {
              line = stream.readLine();
              textEdit-&gt;setText(textEdit-&gt;toPlainText()+"0x"+line+"\n");
              qDebug() &lt;&lt; "line: "&lt;&lt;line;
          } while (!line.isNull());
      }
      file.close();
  }
  </code></pre>
  
  <p>Any suggestions of an alternative way to write this function? </p>