title: Why is my program reading an extra entry from a file in C++?
body: <p>I have a file named 1.txt, it contains 3 lines, each line is stored in an object of class <code>entry</code> as follows:</p>
  <pre><code>1* 10/12/2020 5:30 a 11:15 p 0 0 0 0 -----
  2* 11/12/2020 3:45 a 5:46 a 0 0 0 0 -----
  3* 12/12/2020 5:46 a 4:56 p 34.6 0 0 0 blah
  </code></pre>
  <p>and I'm reading from this file line by line into <code>Entry e</code>, and storing each entry into <code>std::vector&lt;Enrty&gt;records</code> like this:</p>
  <pre><code>void read_records(std::ifstream file, Entry e, std::vector&lt;Entry&gt;&amp;records)
  {
      std::string line;
          std::cout &lt;&lt; &quot;READING TEXT FILE CONTENTS...&quot; &lt;&lt; std::endl;
          while (file)
          {
              getline(file, line);
              e.read_text(tokenize(line)); // tokenize tokenizes line to tokens and e.read_text stores data from that line into e
              records.push_back(e);
              e.reset(); // this resets e back to original state
          }
  }
  </code></pre>
  <p>when I display <code>records</code> after calling this function it gives me an extra Entry in records like so,
  The contents in <code>std::&lt;Entry&gt;records</code> are :</p>
  <pre><code>1* 10/12/2020 5:30 a 11:15 p 0 0 0 0 -----
  2* 11/12/2020 3:45 a 5:46 a 0 0 0 0 -----
  3* 12/12/2020 5:46 a 4:56 p 34.6 0 0 0 blah
  3* 12/12/2020 5:46 a 4:56 p 34.6 0 0 0 blah   // I'm getting this extra entry in records when the file only contains 3 entries.
  </code></pre>
  <p>Please explain why this is happening and now to fix this in visual studio C++.</p>