Something like:
int i = 0;
while(file.ReadString(str))
{
i++;
if (i == 1) {
mainstr += str;
mainstr += _T("\r\n");
}
}
May be a good place to start experimenting. You can play with the value of i when intializing, placement of the initilizing variable, etc.