using fprintf from C instead of C++ fstream