add const to write_until