You just missed one semicolon in Karsten's code, the one at the end of the while statement. It is also no good practice to code a while statement like this. Also Karsten's code was not prepared for when the last line of the file is empty.
Here is a revised version that will help you better:
if (csf.Open(fname, CFile::modeRead))
{
csf.ReadString(buffer);
int out = 0;
out = swscanf_s(buffer, _T("%[^,],%[^,],%[^,],%lf"),str1, 2046, str2, 2046, str3, 2046, &db1) );
pInitialTime = str1;
CString tempBuffer;
while (csf.ReadString (tempBuffer))
if (tempBuffer.GetLength() > 0)
buffer = tempBuffer;
out = swscanf_s(buffer, _T("%[^,],%[^,],%[^,],%lf"),str1, 2046, str2, 2046, str3, 2046, &db1) );
pFinalTime = str1;
}
csf.Close();
of.WriteString(FmtValues1(pInitialTime, pFinalTime));
}