I have a feeling strcmp may be looking for a new line and carriage return character at the end of buffer
No, it isn't. Forget about data_index for the moment. Just print the value in buffer and the value returned by strcmp().
It is quite likely that you need to be using strncmp() instead.