I'm reading through the following text file word for word a replacing the words "@name@" and "@festival@". My program works perfectly for @name@ but only changes the first @festival@, but not the second. I have no idea why.
John Doe
Room 213-A
Generic Old Building
School of Information Technology
Programming State University
New York NY 12345-0987
USA
To: @name@
Subject: Season's greetings: @festival@
Dear @name@,
A very @festival@ to you and your family!
Your sincerely,
John
void Main::readFile()
{
while (v.size() != 0) {
    string name;
    name = v.at(v.size()-1);
    v.pop_back();
    std::ofstream out(name + ".txt");
    ifstream file;
    file.open("letter.txt");
    string word;
    string comma;
    char x;
    word.clear();
    while (!file.eof())
    {
        x = file.get();
        while (x != ' ' && x != std::ifstream::traits_type::eof())
        {
            if (word == "@name@") {
                word = name;
            }
            if (word == "@festival@") {
                word = "THISISATEST!!!!!!!!!!!!!!";
            }
            word = word + x;
            x = file.get();
        }
        out << word + " ";
        word.clear();
    }
}
 
     
     
    