here is your problem, fix the logic.
your opening two handles.
Code:
if ((file = fopen((char*)filename,"r")) == NULL)
	{
//	    AfxMessageBox("Can not open the file: " + filename);  
		bprocessingError=true; // Can not read the file
	}

   else if ((file = fopen( (char *)filename,"r")) != NULL)