fixed an error with writing wav files