Added write function for client