title: C++ Reading File by line and checking if it equals to a specific string
body: <p>I would like to create a program where the user inputs a specific set of numbers of characters, then check an already created file if it has the EXACT same characters typed by the user in each line.</p>
  
  <p>My code:</p>
  
  <pre><code>string line;
  string employeeID;
  
  bool found = false;
  ifstream  stream1("employees.txt", ios::app);
  do{
      cout &lt;&lt; "Enter Employee Password:" &lt;&lt; endl;
      getline(cin, employeeID);
  
      while (!stream1.eof())
      {
          getline(stream1, line);
          if (employeeID == line){
              found = true;
          }
      }
  } while (found == false);
  </code></pre>
  
  <p>And my employees.txt file contains:</p>
  
  <pre><code>ADH4172
  DGGH481
  </code></pre>
  
  <h1>so in other words, I don't want it to proceed with the program if they do not input ADH4172 or DGHH481 as the employee ID. However, the method above does not seem to work. Thanks for your help.</h1>
  
  <p>CODE AFTER FIX:</p>
  
  <pre><code>string line;
      string employeeID;
      bool found = false;
      cout &lt;&lt; "This portion of the program asks for the employee password, and checks its existence from a text files.\nThe passwords are 5555 and 6666. Any other string will not work\n" &lt;&lt; endl;
      do{
          ifstream  input("employees.txt", ios::app);
          cout &lt;&lt; "Enter Employee Password:" &lt;&lt; endl;
          getline(cin, employeeID);
  
          while (!input.eof())
          {
              getline(input, line);
              if (employeeID == line){
                  found = true;
                  input.close();
              }
  
          }
          if (found == false){
              cout &lt;&lt; "Incorrect, try again\n" &lt;&lt; endl;
              input.close();
          }
  
      } while (found == false);
  </code></pre>