title: The Loop statment inside if statment is skipping the first getline(cin, name). What is my mistake here?
body: <p>If you see below code, it asks the user for choice in menu upon entering a number it executes the relevant function. But loop inside if statement is skipping the first getline while outside if statement it is working nice. </p>
  
  <pre><code>int choice;
  cout &lt;&lt; "Enter the number related to below menu: "&lt;&lt;endl;
  cout &lt;&lt; "0: Save to the File: " &lt;&lt; endl;
  cout &lt;&lt; "1: Read from file: " &lt;&lt; endl;
  cout &lt;&lt; "2: Quit the program: " &lt;&lt; endl;
  cin &gt;&gt; choice;
  
  if (choice == 0) {
      for (int i = 1; i &lt; 10; i++) {
          string str = getString(i);
  
          // writing it on file
          filePutContents("db.txt", str, true);
      }
      //reading from file
      readContent();
  }
  </code></pre>
  
  <p>And my getString function is here </p>
  
  <pre><code>    string getString(int i) {
  string name;
  string position;
  string batingAverage;
  string salary;
  
  cout &lt;&lt; "Please enter " &lt;&lt; i &lt;&lt;" baseball player name: ";
  getline(cin, name);
  
  
  cout &lt;&lt; "Please enter " &lt;&lt; i &lt;&lt; " baseball player position: ";
  getline(cin, position);
  
  cout &lt;&lt; "Please enter " &lt;&lt; i &lt;&lt; " baseball player bating Average: ";
  getline(cin, batingAverage);
  
  cout &lt;&lt; "Please enter " &lt;&lt; i &lt;&lt; " baseball player Salary: ";
  getline(cin, salary);
  return " "+ name +" "+ position +" " + batingAverage +" " + salary;}
  </code></pre>
  
  <p>You can better understand from the following image. 
  <a href="https://imgur.com/Fo1sVbz" rel="nofollow noreferrer">https://imgur.com/Fo1sVbz</a></p>
  
  <p>Note Its my first time so pardon my miskates</p>