Add write_some function.