title: C++ reading txt file and cout values not reading whole file
body: <p>I am trying to read in some values in a <code>txt file</code> like so</p>
  
  <pre><code>val1 val2 val3
  val1 val2 val3
  val1 val2 val3
  </code></pre>
  
  <p>Then I am trying to <code>cout</code> to the terminal when I compile the program. 
  The problem I am having is the first line of the text file gets read and prints fine but then I get to random <code>0 0</code> values and then nothing else....</p>
  
  <p>I have no clue where to go from here even to troubleshoot cause I don't get any errors. </p>
  
  <p>I will add that the program doesn't <code>cout</code> anything when compiling in <code>Xcode</code> but when ran from the terminal it shows the line as I explained. </p>
  
  <p>I was thinking maybe this is cause the way my <code>for loop</code> for the <code>vector</code> while <code>cout</code>?</p>
  
  <pre><code>struct Input{
      std::string group;
      float total_pay;
      unsigned int quantity;
  
      Input(std::string const&amp; groupIn, float const&amp; total_payIn, unsigned int const&amp; quantityIn):
      group(groupIn),
      total_pay(total_payIn),
      quantity(quantityIn)
      {}
  };
  
  int main(){
  
      std::ifstream infile("input.txt");
      std::vector&lt;Input&gt; data;
  
      std::string group;
      std::string total_pay;
      std::string quantity;
  
      std::getline(infile,group);
      std::getline(infile,total_pay);
      std::getline(infile,quantity);
  
      while (infile){
          data.push_back(Input(group,atof(total_pay.c_str()),atoi(quantity.c_str())));
  
          std::getline(infile,group);
          std::getline(infile,total_pay);
          std::getline(infile,quantity);
      }
  
  
      //output
      for(Input values : data){
          std::cout &lt;&lt; values.group &lt;&lt; " " &lt;&lt; values.total_pay &lt;&lt; " " &lt;&lt; values.quantity &lt;&lt; '\n';
      }
  
      return 0;
  }
  </code></pre>