amend write_all