You should write a function to remove the punctuation from a string.
Also don't use eof() on the stream, it doesn't work like people expect.
1 2 3 4 5 6 7 8 9 10 11 12
string remove_punctuation(const string& s)
{
// try first to do it yourself
}
// reading the words
string tmp;
while(file >> tmp)
{
string s = remove_punctuation(tmp);
// use s
}