What input did you give it?
What output did you get?
What were the contents of the data file?

You rely heavily on fixed length buffers, yet you have no code for preventing a buffer overflow. This I suspect is the cause of the problem (buffer overflows, that is. For example: char str[5]; strcpy(str,"Hello"); will overflow the buffer).