Index: libmpc/trunk/mpcenc/mpcenc.c
===================================================================
--- libmpc/trunk/mpcenc/mpcenc.c	(revision 317)
+++ libmpc/trunk/mpcenc/mpcenc.c	(revision 323)
@@ -1733,13 +1733,14 @@
         memmove ( Main.S, Main.S + BLOCK, CENTER * sizeof(float) );
 
+        // 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;
+		}
+
         // 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);
-        }
     }
 
