Fixed file write errors.