Currently the FileWriter calls onwriteend on success, and onerror on failure. It should call onwrite on success, onerror on failiure, and then onwriteend in both cases.