I've been trying to insert a node to my tree through file processing but it only always inserts one node then the program will force close itself. I have tried to put the data on a linkedlist and it worked. So probably the problem here is not the file.txt itself but my tree. Can someone tell me where did i do wrong?
Here is my tree algorithm
struct user {
    char username[50];
    int money;
    char favorite[50];
    user *left;
    user *right;
};
user *root = NULL;
user *userTree(char username[], int money, char favorite[]) {
    user *newBranch = (user *) malloc(sizeof(user));
    strcpy(newBranch->favorite, favorite);
    strcpy(newBranch->username, username);
    newBranch->money = money;
    return newBranch;
}
user *insertUser(user *root,char username[], int money, char favorite[]) {
    if (root == NULL) {
        return userTree(username ,money, favorite);
    }
    else if (strcmp(username, root->username) < 0) {
        root->left = insertUser(root->left, username, money, favorite);
    }
    else {
        root->right = insertUser(root->right, username, money, favorite);
    }
    return root;
}
Here is my file processing algorithm
void insertCredential() {
    FILE* fr = fopen("users/users.txt", "r");
    while (!feof(fr)) {
        char username[50], garbage[50], favorite[50];
        int money;
        fscanf(fr, "%[^#]#%[^#]#%d#%[^\n]\n", username, garbage, &money, favorite);
        root = insertUser(root, username, money, favorite);
        puts("test insert");
    }
    fclose(fr);
}
I have tried to put the data in a linked list and it worked but I want to know exactly why can't I insert it on a tree
 
    