'Removes elements from the response before returning to the caller'

def _sanitize(self, resp, command=None):

    cleaned = []
    for line in resp.splitlines():
        if ((command and (line.strip() == command.strip())) or (self._matched_prompt.strip() in line)):
            continue
        cleaned.append(line)
    return '\n'.join(cleaned).strip()
