Remove fflush() call before fclose().