pass in the write argument
add tests