If the functions take a reference to the ifstream object, then they will modify the original "tex" object. When input is read from ifstream, it is discarded from the buffer, so categ() will essentially pickup where stopwo() left off. If the functions take copies of the object, then change them to take references instead.