ensure client is open before writing