change
char str[] = "";
to
char str[MAX_LENGTH+2];
or similar. Your code reads into the buffer str, but str has no memory allocated. So fgets overwrites some data on the stack, including your numbers pointer.
+2 because I assumed that your numbers are up to _MAX_LENGTH_ long and there should additionally be enough space for \n and zero terminator.