title: while(getline(fin, str)){} still processing data even after reaching eof
body: <p>I'm trying to process data I'm reading from a file using getline() as a while condition. However, even when getline reads to the end of my file, it still keeps processing data and I can't figure out why.</p>
  
  <p>I tried putting fin.ignore at the end of my while loop, and that did solve one problem but created another. Let me show you what I mean.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>   int i{ 0 };
     string name_buffer;
     string quantity_buffer;
     string price_buffer;
     ifstream fin("in_inventory.txt");
     if (fin) {
        while (getline(fin, name_buffer, ';') &amp;&amp; i &lt; g_kMaxArray) {
           getline(fin, quantity_buffer, ';');
           getline(fin, price_buffer, '\n');
           p_item_list_[i] =  new Product(stoi(quantity_buffer) == 0, name_buffer, stoi(quantity_buffer), stod(price_buffer));
           i++;
           item_count_++;
        }
     }
     else {
        cout &lt;&lt; "Error: Failed to open input file." &lt;&lt; endl;
     }
     fin.close();
  </code></pre>
  
  <p>I read this text file:</p>
  
  <pre><code>AMD Ryzen 1600X 6-Core CPU;9;99.99
  WD Blue 1TB HDD;24;49.99
  MSI GTX 1080 Duke Graphics Card;6;519.99
  NZXT H442 ATX Case;21;89.99
  MSI B350 ATX Motherboard;19;149.99
  WD Blue 256GB SSD;28;69.99
  Cooler Master Hyper 212 Evo CPU Heatsink;41;15.99
  Corsair Vengance 8Gb (2x4GB) Dual Channel Memory;18;39.99
  Corsair CX650M 650 Watt Powersupply;16;59.99
  Schiit Fulla 2;25;89.99
  Logitech G410 Tenkeyless Mechanical Keyboard;7;79.99
  Corsair H100iv2 All-in-one CPU Water Cooler;14;109.99
  Steel Series Qck+ Mousepad;54;18.99
  TP-Link Archer T6E PCIe WiFi Card;42;39.99
  Logitech G502 Mouse;61;47.00
  Beyerdynamic DT 770 Studio Headphones;36;178.99
  </code></pre>
  
  <p>As far as I can tell there are no missing or extra semicolons and there's no newline characters at the end of the file.</p>
  
  <p>Here's my output without fin.ignore():</p>
  
  <pre><code>____________________________________________________________________________________
  |Item ID|Restocking?|Name                                            |Quantity|Price |
   ------------------------------------------------------------------------------------
  |   5708|   false   |AMD Ryzen 1600X 6-Core CPU                      |9       |99.99 |
  |   2760|   false   |WD Blue 1TB HDD                                 |24      |49.99 |
  |   7220|   false   |MSI GTX 1080 Duke Graphics Card                 |6       |519.99|
  |   4110|   false   |NZXT H442 ATX Case                              |21      |89.99 |
  |   9026|   false   |MSI B350 ATX Motherboard                        |19      |149.99|
  |   9636|   false   |WD Blue 256GB SSD                               |28      |69.99 |
  |   5559|   false   |Cooler Master Hyper 212 Evo CPU Heatsink        |41      |15.99 |
  |   5541|   false   |Corsair Vengance 8Gb (2x4GB) Dual Channel Memory|18      |39.99 |
  |   7406|   false   |Corsair CX650M 650 Watt Powersupply             |16      |59.99 |
  |   2568|   false   |Schiit Fulla 2                                  |25      |89.99 |
  |   4904|   false   |Logitech G410 Tenkeyless Mechanical Keyboard    |7       |79.99 |
  |   7280|   false   |Corsair H100iv2 All-in-one CPU Water Cooler     |14      |109.99|
  |   4299|   false   |Steel Series Qck+ Mousepad                      |54      |18.99 |
  |   8583|   false   |TP-Link Archer T6E PCIe WiFi Card               |42      |39.99 |
  |   1103|   false   |Logitech G502 Mouse                             |61      |47.00 |
  |   4709|   false   |Beyerdynamic DT 770 Studio Headphones           |36      |178.99|
  |   2900|   false   | //This line shouldn't exist
                                                 |36      |178.99| //This line shouldn't exist
   ------------------------------------------------------------------------------------
  </code></pre>
  
  <p>And here's my output with fin.ignore, it gets rid of the extra output, but deletes the first character of the name of the product for every product after the first:</p>
  
  <pre><code> ____________________________________________________________________________________
  |Item ID|Restocking?|Name                                            |Quantity|Price |
   ------------------------------------------------------------------------------------
  |   6293|   false   |AMD Ryzen 1600X 6-Core CPU                      |9       |99.99 |
  |   3407|   false   |D Blue 1TB HDD                                  |24      |49.99 |
  |   3638|   false   |SI GTX 1080 Duke Graphics Card                  |6       |519.99|
  |   2358|   false   |ZXT H442 ATX Case                               |21      |89.99 |
  |   3370|   false   |SI B350 ATX Motherboard                         |19      |149.99|
  |   1620|   false   |D Blue 256GB SSD                                |28      |69.99 |
  |   5632|   false   |ooler Master Hyper 212 Evo CPU Heatsink         |41      |15.99 |
  |   5847|   false   |orsair Vengance 8Gb (2x4GB) Dual Channel Memory |18      |39.99 |
  |   3866|   false   |orsair CX650M 650 Watt Powersupply              |16      |59.99 |
  |   6181|   false   |chiit Fulla 2                                   |25      |89.99 |
  |   1202|   false   |ogitech G410 Tenkeyless Mechanical Keyboard     |7       |79.99 |
  |   5170|   false   |orsair H100iv2 All-in-one CPU Water Cooler      |14      |109.99|
  |   2230|   false   |teel Series Qck+ Mousepad                       |54      |18.99 |
  |   8477|   false   |P-Link Archer T6E PCIe WiFi Card                |42      |39.99 |
  |   5789|   false   |ogitech G502 Mouse                              |61      |47.00 |
  |   5263|   false   |eyerdynamic DT 770 Studio Headphones            |36      |178.99|
   ------------------------------------------------------------------------------------
  </code></pre>
  
  <p>Whats the best solution here? What exactly is going here that's causing this output? Thanks.</p>