change inline->static inline to follow C99 semantics (for Clang)
check error of fread() and fwrite()