Reading only last line of file

I am reading in a .csv file saved from an excel document. When reading the file I have found that my program ONLY reads the last line of the file. The code is as follows.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<fstream>
#include<iostream>
#include<string>
#include<vector>

void processExport(std::string file, std::vector<Record*>* records){
	std::fstream infile(file.c_str(), ios::in);
	
	if(!infile.good()) cout << "File not open" << endl;
	
	std::string buf;
	
	int pos;
	
	
	while(getline(infile,buf)){
		cout << buf << endl;
/*		if (buf.find("LASTNAME")==0) continue;
		
		Record* temp = new Record;
		
		pos = buf.find(',');
		temp->lastName = buf.substr(0,pos);
		buf.erase(0,pos+1);
		
		pos=buf.find(',');
		temp->firstName = buf.substr(0,pos);
		buf.erase(0,pos+1);
		
		pos = buf.find(',');
		temp->userKey = (int) atof(buf.substr(0,pos).c_str());
		buf.erase(0);
		
		records->push_back(temp);
*/	}
	
	
}


When I call the function on a particular file it only prints to the screen the last line of the file. I am not sure why this is the case. Any help would be appreciated.
Topic archived. No new replies allowed.