Modified to write the pcm output to a file