How to loop through the lines on the file

So i want to make a directory, when a certain scope of work is searched, the details of the supplier will appear, my problem is how do i loop through the lines on the file?

My code is like this:
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;

int main()
{
ifstream inFile1;
string Scope;
string cname;
string cperson;
string cnumber;
string Scopedoc;
string cnamedoc;
string cpersondoc;
string cnumberdoc;
int playagain;

inFile1.open("TelephoneDirectory.txt");
//exit if file cannot be opened
if (!inFile1)
{
cout <<"Cannot open input file."<<endl;
return 0;
}

//Order of data from file
inFile1 >>Scopedoc >> cnamedoc >> cpersondoc >> cnumberdoc;
do
{
//Ask user to enter scope of work.
cout<<"Please enter the scope / nature of work: " <<endl;
cin>> Scope;

{
//inFile1 >>Scopedoc >> cnamedoc >> cpersondoc >> cnumberdoc;
if( Scope == Scopedoc)
cout<< "Company Name: \n" << cnamedoc<< "\nContact Person: \n" << cpersondoc<< "\nContact Number: \n" << cnumberdoc <<endl;

else
cout<<"Number was not in directory."<<endl;
}
cout <<"Want to continue looking? 0 for no, 1 for yes. " <<endl;
cin >>playagain;
}
while (playagain == 1);


system("PAUSE");
return 0;

}

and my directory is like this:

Tiles FloorToGo Hans 09351864545
ToiletPartition Jebsen RA 09564875560
Lockset Dorma Steve 09546556123
Tiles Itrade Sandy 09224568916

As it is right now only the first line appears when i search for "Tiles". and when i tried to search for Lockset, Number was not in directory will appear.

Your help is highly appreciated. :)
I re-arranged the program logic a little bit:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include <cmath>

using namespace std;

int main()
{
    string Scopedoc;
    string cnamedoc;
    string cpersondoc;
    string cnumberdoc;

    ifstream inFile1("TelephoneDirectory.txt");
   
    // exit if file cannot be opened   
    if (!inFile1)  
    {
        cout << "Cannot open input file." << endl;
        return 0;
    }

    int playagain = 1;
         
    while (playagain == 1)
    {       
        // Ask user to enter scope of work.
        string Scope;
        cout << "Please enter the scope / nature of work: " << endl;
        cin >> Scope;                      
          
        // read data from file
        
        bool found = false;
        
        while (inFile1 >> Scopedoc >> cnamedoc >> cpersondoc >> cnumberdoc)
        {
            if ( Scope == Scopedoc)
            {
                found = true;
            
                cout << "\nCompany Name:   " << cnamedoc
                     << "\nContact Person: " << cpersondoc
                     << "\nContact Number: " << cnumberdoc 
                     << endl;
           }
        }

        if (!found)
        {
            cout << "Number was not in directory." << endl;
        }        

        cout << "\nWant to continue looking? 0 for no, 1 for yes. " << endl;
        cin >> playagain;
        
        if (playagain == 1)
        {
            inFile1.clear();  // reset flags
            inFile1.seekg(0); // reposition to start  
        }
    }
        

    system("PAUSE");
}

Please enter the scope / nature of work:
Tiles

Company Name:   FloorToGo
Contact Person: Hans
Contact Number: 09351864545

Company Name:   Itrade
Contact Person: Sandy
Contact Number: 09224568916

Want to continue looking? 0 for no, 1 for yes.
1
Please enter the scope / nature of work:
Lockset

Company Name:   Dorma
Contact Person: Steve
Contact Number: 09546556123

Want to continue looking? 0 for no, 1 for yes.
0
Press any key to continue . . .
Thanks so much for the response. More Power! :)
Topic archived. No new replies allowed.