         
         let pos = self.endOfFile
         
-        self.endOfFile = pos + CUnsignedLongLong(dataSize)
+        self.endOfFile = pos + CUnsignedLongLong(blockSize)
         
         return pos;
     }

        return data.writeToURL(self.url, atomically: true)
    }
    
    // #pragma mark - register and endofFile
    
    func seekEndOfFile() -> CUnsignedLongLong {

    var fileOffset : Int = 1
    
    // data.length + header.length;
    let headerSize = sizeof(H)
    let dataSize = sizeof(D)
    let blockSize = sizeof(H) + sizeof(D)  // test as CUnsignedLongLong
    
    var endOfFile: CUnsignedLongLong = 0;
    var unusedDataSegments =  Dictionary<CUnsignedLongLong,Bool>()
