Replace fwrite() call with printf