title: won't read my file in C++ in the login
body: <p>it does write in my file but it seems like it won't read any. it keeps saying "incorrect username or password" , can anyone see the error??? this is the code that i have made, ios::app is for append right> is something like that needed in ifstream as well???  i really don;t know what else to say. i have been trying to get this work the whole day today.</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;fstream&gt;
  #include&lt;string&gt;
  using namespace std;
  int main()
  {
    int command; string name,password,inName, inPassword,regName,regPassword;
   while(1)
   {
  
  
      cout&lt;&lt; " 1. REGISTER \n 2. LOGIN \n 3. EXIT" &lt;&lt;"\n\n";
      cout&lt;&lt; "ENTER YOUR COMMAND NUMBER: \n";
      cin&gt;&gt;command;
      if (command==3)
      {
          return 1;
      }
      if (command == 1)
      {
          ofstream g("Registration.txt", fstream::app);
          if (!g.is_open())
          {
              cout&lt;&lt; "no such file exists \n";
              return 0;
          }
          cout&lt;&lt; "\n\n\n Enter new username: ";
          cin&gt;&gt; regName;
          cout&lt;&lt; "\n New Password: ";
          cin&gt;&gt; regPassword;
          g&lt;&lt;regName; g&lt;&lt;"\n";
          g&lt;&lt; regPassword;
          g.close();
      }
  
      if (command == 2)
      {
          ifstream f("Registration.txt");
          if (!f.is_open())
          {
              cout&lt;&lt; "could not open file \n";
              return 0;
  
          }
          getline(f,name,'\n');
          getline(f,password,'\n');
          f.close();
  
          while (1)
          {
              cout&lt;&lt; "\n\n\n"&lt;&lt; "Enter username: ";
              cin&gt;&gt;inName;
              cout&lt;&lt; "Enter password: ";
              cin&gt;&gt; inPassword;
              if (inName==name &amp;&amp; inPassword== password)
              {
                  cout &lt;&lt; "\n\n\nLOGIN SUCCESSFUL! \n\n\n Welcome!"&lt;&lt; inName;
                  break;
              }
              cout&lt;&lt; "INCORRECT USERNAME OR PASSWORD";
          }
  
          }
      }
  
    return 1;
   }
  </code></pre>