I'm trying to search a text file for any email addresses. I'm trying to get it to print the line that every @ sign appears in. However, it is only printing the @ sign instead of the whole line. And I don't understand why.

//gathering emails
  string Emails;
  int i;
  while (getline(fin,Emails))
  {
	  for (i = 0; i < Emails.length(); i++)
	  {
		  if (Emails[i] == '@')
		  {
			  cout << Emails[i] << endl;
		  }
	  }
  }

Change line 10 to cout<<Emails<<endl; , that will print out the whole string.