How many times are you trying to read the files? It appears to me that you are trying to read each file more than once, without resetting the file flags and FILE*.

You really should be checking that your read operations actually succeeded every time.