Index: /mppenc/branches/zorg/src/bitstream.c
===================================================================
--- /mppenc/branches/zorg/src/bitstream.c	(revision 49)
+++ /mppenc/branches/zorg/src/bitstream.c	(revision 50)
@@ -115,7 +115,12 @@
     if ( fseek ( fp, 22L, SEEK_SET ) < 0 )
         return;
+    fread ( buff, 1, 2, fp );
+    if ( ferror(fp) )
+        return;
+    if ( fseek ( fp, 22L, SEEK_SET ) < 0 )
+        return;
 
     ValidSamples <<= 4;
-    ValidSamples  |= 0x8000;
+    ValidSamples  |= 0x800F & (((Uint) buff[1] << 8) | buff[0]);
     buff [0] = (Uint8_t)(ValidSamples >>  0);
     buff [1] = (Uint8_t)(ValidSamples >>  8);
Index: /mppenc/branches/zorg/src/config.h
===================================================================
--- /mppenc/branches/zorg/src/config.h	(revision 49)
+++ /mppenc/branches/zorg/src/config.h	(revision 50)
@@ -46,5 +46,5 @@
 
 #ifndef MPPENC_VERSION
-# define MPPENC_VERSION   "1.15w-2"
+# define MPPENC_VERSION   "1.15w-6"
 #endif
 
Index: /mppenc/branches/zorg/src/encode_sv7.c
===================================================================
--- /mppenc/branches/zorg/src/encode_sv7.c	(revision 49)
+++ /mppenc/branches/zorg/src/encode_sv7.c	(revision 50)
@@ -93,5 +93,5 @@
     WriteBits ( 1            ,  1 );    // true gapless: used?
     WriteBits ( SamplesRest  , 11 );    // true gapless: valid samples in last frame
-    WriteBits ( 1            , 1 );		// we now support fast seeking
+    WriteBits ( 1            , 1 );     // we now support fast seeking
     WriteBits ( 0            , 19 );
 
Index: /mppenc/branches/zorg/src/mppenc.c
===================================================================
--- /mppenc/branches/zorg/src/mppenc.c	(revision 49)
+++ /mppenc/branches/zorg/src/mppenc.c	(revision 50)
@@ -1662,8 +1662,8 @@
                 return 1;
             }
-            OutputFile = fopen ( OutputName, "wb" );
+            OutputFile = fopen ( OutputName, "w+b" );
             break;
         case MODE_OVERWRITE:
-            OutputFile = fopen ( OutputName, "wb" );
+            OutputFile = fopen ( OutputName, "w+b" );
             break;
         case MODE_ASK_FOR_OVERWRITE:
@@ -1680,5 +1680,5 @@
                                 stderr_printf ( " YES\n" );
             }
-            OutputFile = fopen ( OutputName, "wb" );
+            OutputFile = fopen ( OutputName, "w+b" );
             break;
         }
