which line or lines are giving me the undesired output
int main() {
    // This line causes stdout not to be buffered.
    // Don't change this! Necessary for autotesting.
    setbuf(stdout, NULL);

    struct sockaddr_in *self = init_server_addr(PORT);
    int listenfd = set_up_server_socket(self, 5);

    while (1) {
        int fd = accept_connection(listenfd);
        if (fd < 0) {
            continue;
        }

        // Receive messages
        char buf[BUFSIZE] = {'\1'};
        int inbuf = 0;           // How many bytes currently in buffer?
        int room = sizeof(buf);  // How many bytes remaining in buffer?
        char *after = buf;       // Pointer to position after the data in buf

        int nbytes;
        while ((nbytes = read(fd, after, room)) > 0) {
            // Step 1: update inbuf (how many bytes were just added?)
            inbuf += nbytes;

            int where;

            // Step 2: the loop condition below calls find_network_newline
            // to determine if a full line has been read from the client.
            // Your next task should be to implement find_network_newline
            // (found at the bottom of this file).
            //
            // Note: we use a loop here because a single read might result in
            // more than one full line.
            while ((where = find_network_newline(buf, inbuf)) > 0) {
                // where is now the index into buf immediately after
                // the first network newline
                // Step 3: Okay, we have a full line.
                // Output the full line, not including the "\r\n",
                // using print statement below.
                // Be sure to put a '\0' in the correct place first;
                buf[where - 2] = '\0';

                printf("Next message: %s\n", buf);

                inbuf -= where;
                ;
                memmove(buf, buf + where + 1, inbuf);
            }
            // Step 5: update after and room, in preparation for the next read.
            after = buf;
            room = sizeof(buf) - inbuf;
        }
        close(fd);
        printf("The connection is now closed ...\n");
    }

    free(self);
    close(listenfd);
    return 0;
}

int find_network_newline(const char *buf, int n) {
    for (int i = 0; i < n - 1; i++) {
        if ((buf[i] == '\r') && (buf[i + 1] == '\n')) {
            return i + 2;
        }
    }

    return -1;
}