You have stop reading the file after you found the row you are looking for. Maybe you want to change the function to:
string SearchFunction(string search)
{
int found=0, check=0; //Declare and initialize both variables to 0.
ifstream outfile; //Create object for reading file.
outfile.open("student.txt"); //Open file.
// Also check if found!!!
while(!outfile.eof() && !found) //Continue loop until the end of file.
{
found=0, check=0; //Initialize both variables to 0 again in anticipation of repititions.
getline(outfile, data); //Input one row from file to string variable data.
found=data.find(search, found); //Search for the search term in string data.
if(found!=string::npos) //If search term found.
{
cout<<data<<endl; //Display row.
}
}
outfile.close();
return data;
}