search for string between new line chars in file

Hello, I am making a program to solve word jumbles. It takes in an a string and finds all permutations of the characters and for each permutation checks the string against a wordlist to see if its a real word. The code I have for the word searching function is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
bool CheckWord(string word)
{
    string search = /*'\x0a' + */word + '\x0d'; // Search doesn't find anything with \x0a
    string line = "";
    
    fstream Myfile("wordlist.txt", ios::in | ios::binary);
    if(Myfile.is_open())
    {
        while(!Myfile.eof())
        {
            getline(Myfile, line);
            if(line.find(search) != string::npos)
                return true;
        }
        Myfile.close();
    }
    else
        cout << "Unable to open the wordlist." << endl;
    return false;
}


The problem I am having is that I need to be sure that it only returns true if the word is found on its own line and while I can add \x0D to the end and find good results it won't find ANYTHING if I add the newline char to the front(\x0A).
Any suggestions... (also platform independent would be best)
Thanks in advance.
Could you please rephrase your question, I can't understand what You are talking about.
Sorry. I want to search for a string between two CRLF characters to be sure that the string is on its own line
Solved it. I got confused on what getline() did. the code works perfectly with
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
bool CheckWord(string word)
{
    string search = word;
    string line = "";
    
    ifstream Myfile("wordlist.txt", ios::in);
    if(Myfile.is_open())
    {
        while(!Myfile.eof())
        {
            getline(Myfile, line);
            if(line == search)
            {
                return true;
            }
        }
        Myfile.close();
    }
    else
        cout << "Unable to open the wordlist." << endl;
    return false;
}
Topic archived. No new replies allowed.