         data.append(termData)
         data.append(0x20)
         for (i, p) in preds.keys.sorted().enumerated() {
-            let t = preds[p]!
-            if i > 0 {
-                data.append(contentsOf: [0x20, 0x3b, 0x0a, 0x09]) // space semicolon newline tab
-            }
-            try serialize(t, forPredicate: p, to: &data)
+            if let t = preds[p] {
+                if i > 0 {
+                    data.append(contentsOf: [0x20, 0x3b, 0x0a, 0x09]) // space semicolon newline tab
+                }
+                try serialize(t, forPredicate: p, to: &data)
+            }
         }
         data.append(contentsOf: [0x20, 0x2e, 0x0a]) // space dot newline newline
     }

    }

    public func serialize<T: TextOutputStream, S: Sequence>(_ triples: S, to stream: inout T) throws where S.Element == Triple {
        serializeHeader(to: &stream)
        return try serialize(triples, to: &stream, emitHeader: true)
    }
    

        }
        let subjects = Dictionary(grouping: triples) { $0.subject }
        for (i, s) in subjects.keys.sorted().enumerated() {
            if let triples = subjects[s] {
                if i > 0 {
                    stream.write("\n")
                }
                try serialize(triples, forSubject: s, toStream: &stream)
            }
        }
    }
    
