     
     // #pragma mark - read/write header
     
+    // TODO: similar code for read data and read header (no added value)
+    
     func readHeader() -> H! {
         
-        let data = self.fileHandle.readDataOfLength(sizeof(H))
-        
-        // works only by value?
-        if data {
-            var result = H()
-            
+        let data : NSData! = readHeader()
+        
+        if (data != nil) {
+            
+            var result : H! = nil
+            
+            // TODO: how to read data from NSData to a value variable?
             data.getBytes(&result)
             
             return result

        return self.fileHandle.readDataOfLength(sizeof(D));
    }
    
    
    // #pragma mark WRITE -------------------------------------------------------
    

        while (pos < self.endOfFile) {
            // reade the complete file
            
            var optinalHeader : H! = readHeader()
            
            if var header = optinalHeader {
                
