Hi Valentina, there is no need to explicitely handle file opening/closing. You could make the program accepting input from standard in and then redirect the intended file on program call. e.g.
my_program < my_input_file
Also, there is no need to explicitely find word boundaries,
can gently do such a job for you.
using namespace std;
vector <string> vw;
cin >> word;
if ( ! cin ) break;
cout << "count of words is " << vw.size();