value is declared to be 50 characters but your index variable is unbounded. value is declared on the stack so once index reaches 50, you will start to erase other data on the stack.
As a side note, you can replace:
char value[50];
memset(value,0,sizeof(value));
... with this ...
char value[50] = {0};
Also, I suspect your sample data is missing newlines ("\n") from the end of each line.