I'm in a beginner C++ course, and have gotten stuck on an assignment I've been given. This is the part I'm having trouble with right now:

The program then asks the user for a search string, which may contain white space. The program should search the file for every occurrence of the search string. When the string is found, the line that contains it should be displayed in the following format
nnnnn:Line Contents
That is the line number of the line, 5 columns wide, right justified, followed by a colon, followed by the contents of the line.


And this is what I've got so far:
Code:
#include<iostream>
#include<fstream>
#include<string>
#include<iomanip>
using namespace std;

int main(int argc, char *argv[])
{
	ifstream inFile;
	string fileName,
		   text,
		   toFind;
	size_t found = 0;

	if (argc > 1) 
		fileName = argv[1];
	else 
	{
		cout << "File Name: ";
		getline(cin, fileName);
	};
	inFile.open(fileName.data());

	if (!inFile)
	{
		cout << "Error, cannot open the file";
		exit(1);
	};

	cout << "Enter string to find: ";
	cin >> toFind;
	inFile >> text;
	int lineNum = 1;
	while (getline(inFile, text))
	{
		found = (text.find(toFind));
		if (found != 0)
		{
			cout << setw(5) << lineNum << ":";
			cout << text << endl;
		}
		lineNum++;
		found = 0;
	};

	inFile.close();

	return(0);
}
But this doesn't work. It prints everything in the file, not just the lines where the string is found. Can anyone help me understand what I need to do differently?