Tweak write_items() to take items by-ref