Fix checking whether to use write_attribute