Code:
if(!(psfout = soundout_open("out.wav"))){ cout << "error opening output file\n" << endl; exit(-1);}
	else cout << "soubor <out.wav> otevren pro psani" << endl;

for(int i=0; i<n; i++){

   /*Open input file one by one and write to that output file*/


}

/*Close the output file here, not in the for loop */