add handle_write to stream