Work for me, thanks @Someprogrammerdude
getline(fin, s); n = stoi(s); for (int i = 0; i < n + 1 && std::getline(fin, s); i++) { A.push_back(s); }