The above was lifted straight out of the documentation, QIODevice::Text is needed to convert the line end markers from '\r\n' and is probably the source of your problem.
Hmmm, still doesn't seem to work.

Can you post a bit more code with what you are actually doing in that loop?
Sorry, I probably should've done this in the first place :P

Here is the code for WRITING the file:

Qt Code:
  1. QFile file(fileName);
  2.  
  3. if(!file.open(QIODevice::WriteOnly)){
  4. QMessageBox::information(this, tr("Unable to open file"),
  5. file.errorString());
  6. return;
  7. }
  8.  
  9. QTextStream out(&file);
  10. out << /*column headers*/ << \r\n;
  11.  
  12. for(int i = 0; i < nLines; i++)
  13. {
  14. out << /*column values*/ << \r\n;
  15. }
To copy to clipboard, switch view to plain text mode 

Here's a better look at the code for READING from the file:

Qt Code:
  1. QFile file(fileName);
  2.  
  3. if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
  4. QMessageBox::information(this, tr("Unable to open file"),
  5. file.errorString());
  6. return;
  7. }
  8.  
  9. //I used the approach in lines 12-15 to read the column headers
  10. //because QTextStream::readLine() also made file.atEnd() return
  11. //true, so the while loop was being skipped entirely
  12. char firstLineIterator = 0;
  13. while(firstLineIterator!= 10)
  14. file.getChar(&firstLineIterator);
  15. QTextStream in(&file);
  16.  
  17. while(!file.atEnd())
  18. {
  19.  
  20. //Store file name and direction (The first 2 values in each line in the
  21. //file are strings, the rest are doubles)
  22. QString fileName, direction;
  23. in >> fileName >> direction;
  24.  
  25. //Store double values for the line
  26. double inputArray[32];
  27. for(int i=0; i<32; i++)
  28. in >> inputArray[i];
  29.  
  30. /*store array values into spin boxes on the form*/
  31.  
  32. }
To copy to clipboard, switch view to plain text mode 

I hope this is enough for you to get a better idea of what the problem could be