- fwrite(write_little_endian(0, buf, 4), 4, 1, s->fid);
+ written += fwrite(write_little_endian(0, buf, 4), 4, 1, s->fid);
+
+ // fwrite(*, *, 1, s->fid) was called 13 times, check success
+ if (written != 13) {
+ char errorstr[256];
+ AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));
+ AUBIO_WRN("sink_wavwrite: writing header to %s failed, expected %d"
+ " write but got only %d (%s)\n", s->path, 13, written, errorstr);
+ return AUBIO_FAIL;
+ }