title: stuck at reading credentials from txt file correctly
body: <p>I am stuck at reading credentials from txt file. what am I doing wrong?</p>
  <p>I can successfully create new file each time and open it but don't know in what format should I save so I can read it correctly. like should I make separate file for username/email and passcode or one file. should I save username and passcode at same line or next line.</p>
  <p>I am a student and just trying to make program in order to learn so please avoid any silly mistake made by me.</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  using namespace std;
  bool status;
  //system(&quot;clear&quot;);
  int counter = 0;
  string new_passcode = &quot;0&quot;, confirm_passcode = &quot;0&quot;, em, pw, temp2;
  char acc_check;
  string email, passcode;
  string temp;
  
  string temp_email;
  //int index = 1;ss
  bool login()
  {
  
      //string email, passcode, em, pw;
      ifstream read;
      read.open(&quot;credentials.txt&quot;, ios::in);
      if (read.is_open())
      {
          while (!read.eof())
          {
              getline(read, temp_email);
              //getline(read, pw);
              cout &lt;&lt; temp_email &lt;&lt; endl;
              //cout &lt;&lt; pw &lt;&lt; endl;
          }
          do
          {
              cout &lt;&lt; &quot;Please enter your email id&quot; &lt;&lt; endl;
              cin &gt;&gt; email;
              cout &lt;&lt; &quot;please enter your passcode&quot; &lt;&lt; endl;
              cin &gt;&gt; passcode;
              temp = email + passcode;
  
              if (temp_email == temp &amp;&amp; /*pw == passcode &amp;&amp;*/ counter &lt; 3)
              {
                  cout &lt;&lt; &quot;login successful&quot;;
                  return true;
              }
              else
              {
                  counter++;
                  cout &lt;&lt; &quot;Trials left :&quot; &lt;&lt; 3 - counter &lt;&lt; endl;
              }
  
          } while (temp_email != temp /*&amp;&amp; pw != passcode)*/ &amp;&amp; counter &lt; 3);
  
          cout &lt;&lt; &quot;blocked&quot;;
          //return false;
      }
      else
          cout &lt;&lt; &quot;unable to open file&quot;;
      read.close();
  }
  
  int main()
  {
  
      cout &lt;&lt; &quot;Login syetem&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;Do you already have acc ,press Y/N&quot; &lt;&lt; endl;
      cin &gt;&gt; acc_check;
      if (acc_check == 'N' || acc_check == 'n')
      {
          int passcode_loop = 0;
          do
          {
  
              cout &lt;&lt; &quot;Sign Up!&quot; &lt;&lt; endl;
              cout &lt;&lt; &quot;Enter your email&quot; &lt;&lt; endl;
              getline(cin &gt;&gt; ws, email);
              cin.ignore(1000, '\n');
              cout &lt;&lt; &quot;Enter your passcode&quot; &lt;&lt; endl;
              cin &gt;&gt; new_passcode;
  
              cout &lt;&lt; &quot;confirm your passcode&quot; &lt;&lt; endl;
              cin &gt;&gt; confirm_passcode;
              if (new_passcode == confirm_passcode)
              {
                  passcode_loop = 1;
  
                  ofstream file_2(&quot;credentials.txt&quot;, ios::out | ios::app);
                  file_2 &lt;&lt; email &lt;&lt; new_passcode &lt;&lt; &quot;\n&quot;;
                  file_2.close();
              }
              else
              {
                  cout &lt;&lt; &quot;Passcode didn't match ,enter password again&quot;;
                  system(&quot;clear&quot;);
              }
  
          } while (passcode_loop == 0);
      }
      else if (acc_check == 'Y' || acc_check == 'y')
      {
          login();
      }
      else
          cout &lt;&lt; &quot;invalid answer&quot;;
  
      return 0;
  }
  </code></pre>