i want to open a wav file but it does not work this way. why?

#include<fstream.h>

void main()
{
unsigned long x;
ifstream file1("sourcepathstring");
ofstream file2("targetpathstring");

while(!file1.eof())
{
file1>>x;
cout<<x<<endl;
file2<<x<<endl;
}
file1.close();
file2.close();
}

it is not working this way? why?
if i have char instead of unsigned long it runs when i convert from
char to ASCII number, but this way i am loosing data, also i want
to know WHY it is not working.
thanks