why does it keep running

char *trim_line(char *line) {
    int i = strlen(line) - 1;
    while (i >= 0) {
        if (line[i] == '\r' || line[i] == '\n' || line[i] == ' ') {
            line[i] = '\0';
            i -= 1;
        } else {
            break;
        }
    }
    while (line[0] == ' ') {
        line += 1;
    }
    return line;
}