You called fopen() to open files but failed to call fclose.
fh = fopen("test.txt", "w" ); if( fh ) { // fclose( fh ); // fclose() SHOULD be called }