The functions you use give no reason to expect an issue, so I can't say what causes this. (although Jochens suggestion - a caching issue - seems plausible)
However, there is no need to call remove at all if you open the file for writing anyway: if the file already exists, it will be emptied and treated as new. See
http://www.cplusplus.com/reference/cstdio/fopen/[
^]