fix file-writer: add error listener

Add error listener in `file-writer.js`.