try utimes(f, NULL) before trying to read/write the file