protected String readCommandResponse(BufferedReader in)
    {
        boolean internalBuffer = false;
        String response = "";
        String output;

        // Checking the param
        if (in == null) {
            try {
                in = new BufferedReader(new InputStreamReader(this.socket.getInputStream()));
                internalBuffer = true;
            } catch (IOException e) {
                System.out.println("Could not get input stream for server at " + this.address);
                System.exit(-1);
            }
        }

        // Reading the command output
        try {
            output = in.readLine();

            while (output != null) {
                response += output + "\r\n";
                output = in.readLine();
            }
        } catch (IOException e) {
            response = "Could not execute command";
        }

        // Some info in case no response is given
        if (response.length() == 0) {
            response = "No response received";
        }

        // If the BufferedReader was created internally it will be closed internally
        if (internalBuffer) {
            try {
                in.close();
            } catch (IOException e) {
                // Doesn't matter if it's not closed (for now)
            }
        }

        return response;
    }