.wav file not playing properly



Hi experts,

I have an ATl control which contains a player. The player do copies a
file from the webserver and copy that file to local system and then
play that locally.. But when I tried to play that file ,some of the
files looks scrambled. I donno y that happends..


my function is ike this.
void readFromURL(char *urlName)
{
CString temp = urlName;
temp += " Path in readURL";
//MessageBox(temp);
HINTERNET hOpen;
HINTERNET hOpenUrl;
char lpBufferA[1000];

DWORD dwRead,dwTotalBytesRead;
int BUFFER_SIZE =1000;
FILE* outFile2 = fopen("E:\\tempfile.wav", "w");// Need to change the
path..

hOpen = InternetOpen(_T(""),INTERNET_OPEN_TYPE_PRECONFIG
,NULL,NULL,0);//INTERNET_FLAG_ASYNC);
if(hOpen!=NULL)
{
hOpenUrl = InternetOpenUrl(hOpen,urlName ,NULL,
0,INTERNET_FLAG_DONT_CACHE, 0);

if(hOpenUrl!=NULL)
{

do
{
if(!InternetReadFile(hOpenUrl, (LPVOID)&lpBufferA, BUFFER_SIZE,
&dwRead))
{
break;

}
else
{
fwrite(lpBufferA, 1, dwRead, outFile2);

}
dwTotalBytesRead += dwRead;
} while (dwRead > 0);
}
}
InternetCloseHandle(hOpenUrl);

fclose(outFile2);
Speaker->SetPath("E:\\tempfile.wav");
Speaker->Initialize();
Speaker->SetPosition(0);

Speaker->SetVolume(lVol);
Speaker->Play();


}


Is there anything missing in my code ..please help..


thanx in advance
suje

.