 (add-context-input-format :csv
                           (fn [rdr]
                             (try
-                             (re-matches #"^[^,]+,[^,]+$" (.readLine rdr))
+                             (re-matches #"^[^,]+,[^,]+$" (read-line))
                              (catch Exception _))))
 
 (define-context-input-format :csv
   [file]
-  (let [in (reader file)]
+  (with-in-reader file
     (loop [inz #{}]
-      (let [line (.readLine in)]
+      (let [line (read-line)]
         (if (not line)
           (make-context-nc (set-of g [[g m] inz])
                            (set-of m [[g m] inz])


(add-context-input-format :simple
                          (fn [rdr]
                            (= "conexp-clj simple" (.readLine rdr))))

(define-context-output-format :simple
  [ctx file]


(define-context-input-format :colibri
  [file]
  (with-in-reader file
    (loop [objs #{},
           inz  #{}]
      (let [line (read-line)]
        (cond
         (not line)
         (make-context-nc objs (set-of m [[g m] inz]) inz),
         (or (re-matches #"^\s*$" line)     ; blank
             (re-matches #"^\s*#.*$" line)) ; comment
         (recur objs inz),
         :else
         (let [[_ g atts] (re-matches #"^\s*(.+)\s*:\s*(.+)?\s*;\s*(?:#.*)?$" line)
               atts (and atts (split atts #"\s+"))]
           (recur (conj objs g) (union inz (set-of [g m] [m atts])))))))))


;; Comma Seperated Values (.csv)
