C reading from a file with multiple threads

I'm trying to understand how threads work in C, so I set a challenge for myself. Reading a file with X many threads (X determined during run time). What my code supposed to do is, let's say that file is 150 lines and I've created 10 threads. Then each thread should read 15 lines and it should keep going on until the end. (to check if they're reading the file I'm printing it on the terminal)

thread 0: 0 - 14
thread 1: 15 - 29
...

That's the intention but what happens is:

duman@ubuntu:~/Desktop/testzone$ gcc multithread.c -o test -lpthread
duman@ubuntu:~/Desktop/testzone$ ./test
10 
Lines per thread: 15
I am in thread no : 1 with Thread ID : 93924
I am in thread no : 0 with Thread ID : 93923
I am in thread no : 2 with Thread ID : 93925
I am in thread no : 3 with Thread ID : 93926
I am in thread no : 4 with Thread ID : 93927
I am in thread no : 5 with Thread ID : 93928
Line 0: Star Wars is an American epic space opera media franchise, centered on a film series created by George Lucas. 

Not even all threads are started, everything is a mess and I'm at loss.

I tried to add pthread_mutex_lock(&input_queue); but result didn't change:

duman@ubuntu:~/Desktop/testzone$ ./test
10
Lines per thread: 15
I am in thread no : 0 with Thread ID : 93995
I am in thread no : 2 with Thread ID : 93997
I am in thread no : 1 with Thread ID : 93996
I am in thread no : 3 with Thread ID : 93998
Line 0: Star Wars is an American epic space opera media franchise, centered on a film series created by George Lucas. 

Line 1: It depicts the adventures of various characters "a long time ago in a galaxy far, far away".

I am in thread no : 4 with Thread ID : 93999
I am in thread no : 5 with Thread ID : 94000
Line 2: The franchise began in 1977 with the release of the film Star Wars (later subtitled Episode IV: A New Hope in 1981), which became a worldwide pop culture phenomenon. 

Then I wanted to experiment further and created a function to let me understand what's going on better.

duman@ubuntu:~/Desktop/testzone$ ./test
10
Lines per thread: 15
I am in thread no : 1 with Thread ID : 94030
Global number: 0, 
I am in thread no : 0 with Thread ID : 94029
Global number: 15, 
I am in thread no : 2 with Thread ID : 94031
Global number: 30, 
I am in thread no : 3 with Thread ID : 94032
Global number: 45, 
I am in thread no : 4 with Thread ID : 94033
Global number: 60, 
I am in thread no : 6 with Thread ID : 94035
Global number: 75, 
I am in thread no : 7 with Thread ID : 94036
Global number: 90, 
I am in thread no : 8 with Thread ID : 94037
Global number: 105, 
I am in thread no : 9 with Thread ID : 94038
Global number: 120, 
I am in thread no : 5 with Thread ID : 94034
Global number: 135, 

Result looks uniform and normal when I try this but reading from a file ruins everything. Considering this I know that issue is at my read_file function.

This is my code, what am I doing wrong so that file won't get read? Thank you!

#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <string.h>

void *threadFunction(void*);
int read_file(char*, int);
int line_count(char*);
int ceiling(double);
int global_debug_function(int); //remove this later
pthread_mutex_t input_queue = PTHREAD_MUTEX_INITIALIZER;

int global_line_count = 0;
int global_line_count_per_thread = 0;
int global_cursor = 0;

int global_debug_data = 0; //remove this later

int main()
{
    pthread_mutex_init(&input_queue, NULL);
    int lines = line_count("input.txt");
    global_line_count = lines;

    int n = 0, i = 0, retVal = 0;
    pthread_t *thread;

    scanf("%d", &n); // gets N amount of thread creation order from user

    if(n == 0)
        return 0;

    int lines_per_thread = ceiling(lines / (double)n);
    global_line_count_per_thread = lines_per_thread;

    printf("Lines per thread: %d\n", global_line_count_per_thread);

    thread = (pthread_t *) malloc (n*sizeof(pthread_t));

    for (i = 0; i < n; i++)
    {
        retVal = pthread_create(&thread[i],NULL,threadFunction,(void *)(intptr_t)i);

        if(retVal != 0)
        {
            printf("pthread_create failed in %d_th pass\n",i);
            exit(EXIT_FAILURE);        
        }
    }

    for(i = 0; i < n; i++)
    {
        retVal = pthread_join(thread[i],NULL);

        if(retVal!=0)
        {
            printf("pthread_join failed in %d_th pass\n", i);
            exit(EXIT_FAILURE);        
        }
    }
}
void *threadFunction (void *arg)
{
    int threadNum = (int)(intptr_t) arg;
    pid_t tid = syscall(SYS_gettid);
    printf("I am in thread no : %d with Thread ID : %d\n", threadNum, (int)tid);
    read_file("input.txt", global_line_count_per_thread);
    //global_debug_function(global_cursor);
}

int global_debug_function(int number)
{
    printf("Global number: ");
    int start = global_cursor;
    printf("%d, ", start);
    start++;
    printf("\n");
    global_cursor += global_line_count_per_thread;
}

int ceiling(double input)
{
    int base = (int)input;
    double rest = input - base;
    if(rest > 0.0 && rest < 1.0)
        input++;

    return input;
}

int line_count(char* file_name)
{
    FILE *fp = fopen(file_name, "r");
    int ch = 0;
    int lines = 0;

    if (fp == NULL)
        return 0;

    lines++;
    while(!feof(fp))
    {
        ch = fgetc(fp);

        if(ch == '\n')
            lines++;
    }

    fclose(fp);
    return lines;
}

int read_file(char* file_name, int line)
{
    int end, loop;
    char str[9999];

    pthread_mutex_lock(&input_queue);
    FILE *fd = fopen(file_name, "r");

    if (fd == NULL) {
        printf("Failed to open file\n");
        return -1;
    }

    int counter = 0;
    for(end = loop = global_cursor; loop < global_line_count; ++loop)
    {
        if(0 == fgets(str, sizeof(str), fd))
        {
            end = 1;
            break;
        }
        if(loop == global_line_count_per_thread)
            break;
        printf("Line %d: %s\n", loop, str);
        counter++;
    }

    fclose(fd);

    pthread_mutex_unlock(&input_queue);
    global_cursor += global_line_count_per_thread;
    global_line_count_per_thread += global_line_count_per_thread;
    return counter;
}

Edit:

If you want to try yourself,

Here's the code: https://paste.ubuntu.com/p/2MCbTmmcM4/

Here's the text: https://paste.ubuntu.com/p/wWGCWNRDC8/