<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _read(self, size):
 """ Reads size number of bytes from Scratch and returns data as a string """

        data = ''
        while len(data) < size:
            try:
                chunk = self.socket.recv(size-len(data))
            except socket.error as (err, msg):
                self.connected = False
                raise ScratchError("[Errno %d] %s" % (err, msg))
            if chunk == '':
                self.connected = False
                raise ScratchConnectionError("Connection broken")
            data += chunk
        return data