Error reading a .PCM file
That sure looks like your are including the .WAV file header as part of your data.

When you read your file in, and write it out, using the file operations, you are not accounting for the header.  The header can vary in size (it's actually three RIFF headers), but is usually 44 bytes long.



These are the headers in my own (C++) words:


struct FirstHeader
{
char     RiffID[4];
int      RiffLength;
char     WaveID[4];
char     FormatID[4];
int      FormatLength;
};

struct SecondHeader
{
short    Always0x01;
short    TrackCount;
int      SamplesPerSecond;
int      BytesPerSecond;
short    BytesPerSample;
short    BitsPerReading;
char     Filler[16];
};

struct ThirdHeader
{
char     DataID[4];
int      DataLength;
};


Do a search on "Wav file header" and you can get lots of details.  If you don't need any of the parameters, I suppose just looking for the "data" in the header and the next 4 bytes are the UINT32 value of the length.  So your data starts the byte after.

Otherwise, follow the RiffLength and FormatLength to get to the DataID field.

The file can be mono or stereo, 8 16 or 24 bit, etc.