Fixed a problem that was causing the fgets() to not read the file. This was because the same pointer was being used for two fgets() and the file pointer was probably at EOF in the second time so was getting a NULL for return value in fgets()