too. Don't write to file and especially don't close handle if file couldn't be created. Set delete disposition if writing failed, instead of calling unlink_nt.