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:
using namespace std;

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

	if (argc > 1) 
		fileName = argv[1];
		cout << "File Name: ";
		getline(cin, fileName);

	if (!inFile)
		cout << "Error, cannot open the file";

	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;
		found = 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?