     }
 
     public func finalizedData() -> Data {
+        guard
+            mode == .writeOnly
+            else { return data }
         setNextBits(UInt8(bitsLeftInWriteBuffer), from: 0)
-        if( bitsLeftInWriteBuffer != 8 ) {
+        if bitsLeftInWriteBuffer != 8 {
             data.append(writeBuffer)
         }
         let finalizedData = data

    }

    public func setNextBits(_ bitsToWrite: UInt8, from bits: UInt64) {
        if( bitsToWrite > 64 ) {
            return
        }

        var shiftedBits = bits << (64 - bitsToWrite.toU64)
        var bitsLeftToWrite = bitsToWrite
        while bitsLeftToWrite > 0 {

    }

    public func dump() {
        var bits = ""
        while let bit = getNextBit() {
            bits += "\(bit)"
        }
        print(bits)
    }
