for (i=total.begin(); i!= total.end(); i++){ // ignore all comments... don't get rid of stuff like "channel #main" std::string aline = *i; for (int j = 0; j < aline.size(); j++ ){ if(aline[j] == ' ') // # always precede comments, even if there are spaces before the comment continue; if(aline[j] == '#') std::cout << "comment" << std::endl; total.erase(i); break; } }