why is this stuck in an infinite loop
char *read_input(int fd) {
    char buf[INPUT_BUFFER_SIZE + 1];

    // Read user input and handle partial reads
    int inbuf = 0;           // Number of bytes in buf
    int room = sizeof(buf);  // How many bytes left in the buf
    char *after = buf;       // Pointer to the position after the data

    int nbytes;

    int command_read = 1;  // Store if a full line has been read

    while ((nbytes = read(fd, after, room)) > 0 || command_read == 1) {
        inbuf += nbytes;
        int where;

        if ((where = find_network_newline(buf, inbuf)) > 0) {  // When full line is read
            buf[where - 2] = '\0';                             // Null terminate the buffer

            // Update inbuf
            inbuf -= where;

            // Move everything after the full
            memmove(buf, buf + (sizeof(char) * where), inbuf);
            command_read = 0;
        }
        // Update after and room
        after = &buf[inbuf];
        room = INPUT_BUFFER_SIZE - inbuf;

        // Check for closed connection
        if (nbytes == 0) {
            close(fd);
            return NULL;
        }
    }
    close(fd);

    // Return the input
    char *input = malloc(sizeof(char) * (strlen(buf) + 1));
    if (input == NULL) {
        perror("malloc");
        exit(1);
    }
    strcpy(input, buf);

    input[strlen(buf)] = '\0';
    return input;
}