def _write(self, data):
        """
        Writes string data out to Scratch
        """
        total_sent = 0
        length = len(data)
        while total_sent < length:
            try:
                sent = self.socket.send(data[total_sent:])
            except socket.error as (err, msg):
                self.connected = False
                raise ScratchError("[Errno %d] %s" % (err, msg))
            if sent == 0:
                self.connected = False
                raise ScratchConnectionError("Connection broken")
            total_sent += sent
Writes string data out to Scratch