I wrote the code below to download a zip file from a web site using http. However when I try it out, it seems that the zip file would be slightly larger than the original file by a few hundred bytes. What am I doing wrong? I kinda suspect that it is due to fwrite(). Or could anyone suggest a better method? Thanks.

int iNumberOfBytesRead;
void *vBytesReadFromFile;
CInternetSession internetSession;
CHttpFile* httpFile = (CHttpFile*)internetSession.OpenURL(url);

vBytesReadFromFile = malloc(sizeof(char) * 4096);

while (1)
{
iNumberOfBytesRead = httpFile->Read(vBytesReadFromFile, 4096);
fwrite(vBytesReadFromFile, iNumberOfBytesRead, 1, fOutput);
if (iNumberOfBytesRead != 4096)
break;
}

httpFile->Close();
fclose(fOutput);