Removing *Unchanged* Output File (ofstream) :: C++
I am working on an interesting and simple problem. A program I am working on initializes an ofstream object. It does calculations (arbitrary) and writes to the output file. The problem is sometimes it writes new data and sometimes it does not. I am currently using a bool to make sure if it does not write new data, then it should remove the output file when it finishes. There is one false assumption. I am assuming the output file is always empty. That is not true because the output file is openned with "ios::app," which is appending mode. The program sometimes remove files that are not empty.
I tried using the empty() function, but it does not work for an ofstream object. I would like to know the best way to check to make sure an ofstream object is *empty* return from the a end of class or before the program closes.