The main problem with reading the file twice. the code is
std::fstream fs; std::vector buffer1; fs.open("a file location", std::fstream: