Veramente a me funziona perfettamente.

Probabilmente il tuo compilatore C++ ha qualche bug nella gestione dei file ...