You might get further with "r+" rather than "w+".
fopen - C++ Reference

But then again, I would follow jimblumberg and use open/close etc.