Factor out writes as well, and make read => readall