# CodeGuru Technical FAQs > CodeGuru Individual FAQs >  How to read a text file line by line?

## ovidiucucu

*Q:* How to read a text file line by line?

*A:* Simply, by using CStdioFile MFC class.
As for example:


```
void CWhateverClass::ReadTextFile(LPCTSTR pszFileName, CStringArray& arrLines) 
{ 
   arrLines.RemoveAll(); 
   CString strLine; 
   TRY 
   { 
      CStdioFile file(pszFileName, CFile::modeRead); 
      while(file.ReadString(strLine)) 
         arrLines.Add(strLine); 
   } 
   CATCH_ALL(e) 
   { 
      e->ReportError(); // shows what's going wrong 
   } 
   END_CATCH_ALL 
}
```

----------

