You're mixing your output and input modes.
Use fprintf() for text mode, and you can use fscanf(), (or any other text mode file reader), to read the data back into your program.
Use fwrite() to write out data in binary mode, and use fread() to read it back into your program.
It's always good to be specific when you open files:
Not just mode "r" for reading. Either "rt" or "rb", please. Be specific, either text or binary. Don't leave it up to some global variable buried in a header file, somewhere.