title: ifstream won't open file after selecting menu choice
body: <p>So my main code is a menu.</p>
  
  <pre><code>BankAccount BA;
  ifstream fin;
  int UserAction = -1;
  
  while (UserAction != 0) {
      cout &lt;&lt; "menu here";
      cin &gt;&gt; UserAction;
  
      if (UserAction == 1)
          BA.getInstance(BA); //Input by keyboard. Works fine.
      if (UserAction == 2)
          BA.getInstance(BA, fin); //Input by file.
  }
  </code></pre>
  
  <p>If I were to choose option #2, it would execute this code:</p>
  
  <pre><code>void BankAccount::getInstance(BankAccount &amp;BA, ifstream &amp;fin) {
      string actN, fname, lname, InputFileName;
      double bal;
  
      fin.sync();
      cout &lt;&lt; "Please enter input file path: ";
      getline(cin, InputFileName);
      if (fin.fail())
          cout &lt;&lt; "failed";
      else {
          fin.open(InputFileName.c_str());
          BA.getInstance(BA, fin);
      }
  
      fin &gt;&gt; actN;
      fin &gt;&gt; lname;
      fin &gt;&gt; fname;
      fin &gt;&gt; bal;
      BA = BankAccount(actN, lname, fname, bal);
  }
  </code></pre>
  
  <p>After entering the file path, and pressing enter, it would say failed and kick me to menu. If I put cin.sync(); where fin.sync is, it would just keep looping me to enter in the file path. Note that it works outside the menu though. How would I fix it so that it would open the file path correctly without issues so it could process the information?</p>