             newFile = true
         }
         
+        self.fileHandle = NSFileHandle.fileHandleForUpdatingURL(url, error: &self.error)
         self.endOfFile = self.fileHandle.seekToEndOfFile()
         
-        self.fileHandle = NSFileHandle.fileHandleForUpdatingURL(url, error: &self.error)
+        readUnusedDataSegments()
     }
     
     // override in subclasses and update fileOffset if required

        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>()
