std::string _str; _file.seekg(std::ios::beg); while(!_file.eof()) { if(_file.good()) { // create local buffer std::string _buf; std::getline(_file, _buf); // append to _str . alt: _str.append(_buf); _str += (_buf); } };