Use revert() instead of close() when processing fails Otherwise we might write partial changes to the underlying file which is unexpected.