/// <summary>
        /// Finish the stream
        /// </summary>
        /// <param name="bitstream"></param>
        public override void WriteFooter(Bitstream bitstream)
        {
            if (Options.HasFlag(OptionFlags.DumpState))
            {
                WriteLine();
            }
            Finish(bitstream);

            // insert the bitlength of the compressed portion
            bitLength = bitstream.Length - whereToInsertBitlength;
            var lengthBitstream = new Bitstream();

            UniversalCodec.Lomont.EncodeLomont1(lengthBitstream, bitLength, 8, -1);
            bitstream.InsertStream(whereToInsertBitlength, lengthBitstream);
            //Console.WriteLine($"Arith encode bitsize {bitLength} at {whereToInsertBitlength} final {bitstream.Length}");
        }