Index: /libmpc/trunk/mpcenc/mpcenc.c
===================================================================
--- /libmpc/trunk/mpcenc/mpcenc.c	(revision 324)
+++ /libmpc/trunk/mpcenc/mpcenc.c	(revision 325)
@@ -1733,14 +1733,14 @@
         memmove ( Main.S, Main.S + BLOCK, CENTER * sizeof(float) );
 
+        // read samples
+        CurrentRead     = Read_WAV_Samples ( &Wave, (int)minf(BLOCK, SamplesInWAVE - AllSamplesRead), &Main, CENTER, ScalingFactorl, ScalingFactorr, &Silence );
+        AllSamplesRead += CurrentRead;
+
         // adapt SamplesInWAV to the real number of contained samples
 		if ( myfeof (Wave.fp) ) {
 			stderr_printf ( "WAVE file has incorrect header: header: %.3f s, contents: %.3f s    \n",
 							(long double)(SamplesInWAVE) / m.SampleFreq, (long double)(AllSamplesRead) / m.SampleFreq);
-			break;
+			SamplesInWAVE = AllSamplesRead;
 		}
-
-        // read samples
-        CurrentRead     = Read_WAV_Samples ( &Wave, (int)minf(BLOCK, SamplesInWAVE - AllSamplesRead), &Main, CENTER, ScalingFactorl, ScalingFactorr, &Silence );
-        AllSamplesRead += CurrentRead;
     }
 
@@ -1760,6 +1760,5 @@
 	writeBlock(&e, "SE", MPC_FALSE, 0); // write end of stream block
 
-	if (SamplesInWAVE != AllSamplesRead) {
-		SamplesInWAVE = AllSamplesRead;
+	if (Wave.PCMSamples != AllSamplesRead) {
 		fseek(e.outputFile, e.seek_ref + 4, SEEK_SET);
 		writeStreamInfo ( &e, m.Max_Band, m.MS_Channelmode > 0, SamplesInWAVE, 0,
