private String getLine(int index) {
        // get the line that contains input[index]. Assume input[index] is at a
        // token, not
        // a white space or newline

        int i;
        if (input.length <= 1) {
            return "";
        }
        i = index;
        if (i <= 0) {
            i = 1;
        } else if (i >= input.length) {
            i = input.length;
        }

        StringBuffer line = new StringBuffer();
        // go to the beginning of the line
        while (i >= 1 && input[i] != '\n') {
            i--;
        }
        if (input[i] == '\n') {
            i++;
        }
        // go to the end of the line putting it in variable line
        while (input[i] != '\0' && input[i] != '\n' && input[i] != '\r') {
            line.append(input[i]);
            i++;
        }
        return line.toString();
    }