Index: lemon/lgf_writer.h
===================================================================
--- lemon/lgf_writer.h	(revision 291)
+++ lemon/lgf_writer.h	(revision 293)
@@ -56,5 +56,5 @@
     template <typename T>
     bool operator<(const T&, const T&) {
-      throw FormatError("Label map is not comparable");
+      throw DataFormatError("Label map is not comparable");
     }
 
@@ -204,5 +204,5 @@
           _map.find(str);
         if (it == _map.end()) {
-          throw FormatError("Item not found");
+          throw DataFormatError("Item not found");
         }
         return it->second;
@@ -224,5 +224,5 @@
           ::const_iterator it = _map.find(val);
         if (it == _map.end()) {
-          throw FormatError("Item not found");
+          throw DataFormatError("Item not found");
         }
         return (_graph.direction(val) ? '+' : '-') + it->second;
@@ -353,14 +353,14 @@
 
   template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(std::ostream& os,
-                                       const Digraph& digraph);
+  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
+                                       std::ostream& os = std::cout);
 
   template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const std::string& fn,
-                                       const Digraph& digraph);
+  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
+                                       const std::string& fn);
 
   template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const char *fn,
-                                       const Digraph& digraph);
+  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
+                                       const char *fn);
 
   /// \ingroup lemon_io
@@ -383,5 +383,5 @@
   ///
   ///\code
-  /// DigraphWriter<Digraph>(std::cout, digraph).
+  /// DigraphWriter<Digraph>(digraph, std::cout).
   ///   nodeMap("coordinates", coord_map).
   ///   nodeMap("size", size).
@@ -453,6 +453,6 @@
     /// Construct a directed graph writer, which writes to the given
     /// output stream.
-    DigraphWriter(std::ostream& is, const Digraph& digraph)
-      : _os(&is), local_os(false), _digraph(digraph),
+    DigraphWriter(const Digraph& digraph, std::ostream& os = std::cout)
+      : _os(&os), local_os(false), _digraph(digraph),
         _skip_nodes(false), _skip_arcs(false) {}
 
@@ -461,9 +461,7 @@
     /// Construct a directed graph writer, which writes to the given
     /// output file.
-    DigraphWriter(const std::string& fn, const Digraph& digraph)
+    DigraphWriter(const Digraph& digraph, const std::string& fn)
       : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
-        _skip_nodes(false), _skip_arcs(false) {
-      if (!(*_os)) throw IoError("Cannot write file", fn);
-    }
+        _skip_nodes(false), _skip_arcs(false) {}
 
     /// \brief Constructor
@@ -471,9 +469,7 @@
     /// Construct a directed graph writer, which writes to the given
     /// output file.
-    DigraphWriter(const char* fn, const Digraph& digraph)
+    DigraphWriter(const Digraph& digraph, const char* fn)
       : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
-        _skip_nodes(false), _skip_arcs(false) {
-      if (!(*_os)) throw IoError("Cannot write file", fn);
-    }
+        _skip_nodes(false), _skip_arcs(false) {}
 
     /// \brief Destructor
@@ -501,10 +497,10 @@
   private:
 
-    friend DigraphWriter<Digraph> digraphWriter<>(std::ostream& os,
-                                                  const Digraph& digraph);
-    friend DigraphWriter<Digraph> digraphWriter<>(const std::string& fn,
-                                                  const Digraph& digraph);
-    friend DigraphWriter<Digraph> digraphWriter<>(const char *fn,
-                                                  const Digraph& digraph);
+    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
+                                                  std::ostream& os);
+    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
+                                                  const std::string& fn);
+    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
+                                                  const char *fn);
 
     DigraphWriter(DigraphWriter& other)
@@ -913,7 +909,7 @@
   /// \relates DigraphWriter
   template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(std::ostream& os,
-                                       const Digraph& digraph) {
-    DigraphWriter<Digraph> tmp(os, digraph);
+  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
+                                       std::ostream& os = std::cout) {
+    DigraphWriter<Digraph> tmp(digraph, os);
     return tmp;
   }
@@ -924,7 +920,7 @@
   /// \relates DigraphWriter
   template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const std::string& fn,
-                                       const Digraph& digraph) {
-    DigraphWriter<Digraph> tmp(fn, digraph);
+  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
+                                       const std::string& fn) {
+    DigraphWriter<Digraph> tmp(digraph, fn);
     return tmp;
   }
@@ -935,7 +931,7 @@
   /// \relates DigraphWriter
   template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const char* fn,
-                                       const Digraph& digraph) {
-    DigraphWriter<Digraph> tmp(fn, digraph);
+  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
+                                       const char* fn) {
+    DigraphWriter<Digraph> tmp(digraph, fn);
     return tmp;
   }
@@ -945,11 +941,12 @@
 
   template <typename Graph>
-  GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph);
+  GraphWriter<Graph> graphWriter(const Graph& graph,
+                                 std::ostream& os = std::cout);
 
   template <typename Graph>
-  GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph);
+  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
 
   template <typename Graph>
-  GraphWriter<Graph> graphWriter(const char *fn, const Graph& graph);
+  GraphWriter<Graph> graphWriter(const Graph& graph, const char *fn);
 
   /// \ingroup lemon_io
@@ -1013,6 +1010,6 @@
     /// Construct a directed graph writer, which writes to the given
     /// output stream.
-    GraphWriter(std::ostream& is, const Graph& graph)
-      : _os(&is), local_os(false), _graph(graph),
+    GraphWriter(const Graph& graph, std::ostream& os = std::cout)
+      : _os(&os), local_os(false), _graph(graph),
         _skip_nodes(false), _skip_edges(false) {}
 
@@ -1021,9 +1018,7 @@
     /// Construct a directed graph writer, which writes to the given
     /// output file.
-    GraphWriter(const std::string& fn, const Graph& graph)
+    GraphWriter(const Graph& graph, const std::string& fn)
       : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
-        _skip_nodes(false), _skip_edges(false) {
-      if (!(*_os)) throw IoError("Cannot write file", fn);
-    }
+        _skip_nodes(false), _skip_edges(false) {}
 
     /// \brief Constructor
@@ -1031,9 +1026,7 @@
     /// Construct a directed graph writer, which writes to the given
     /// output file.
-    GraphWriter(const char* fn, const Graph& graph)
+    GraphWriter(const Graph& graph, const char* fn)
       : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
-        _skip_nodes(false), _skip_edges(false) {
-      if (!(*_os)) throw IoError("Cannot write file", fn);
-    }
+        _skip_nodes(false), _skip_edges(false) {}
 
     /// \brief Destructor
@@ -1061,10 +1054,10 @@
   private:
 
-    friend GraphWriter<Graph> graphWriter<>(std::ostream& os,
-                                            const Graph& graph);
-    friend GraphWriter<Graph> graphWriter<>(const std::string& fn,
-                                            const Graph& graph);
-    friend GraphWriter<Graph> graphWriter<>(const char *fn,
-                                            const Graph& graph);
+    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
+                                            std::ostream& os);
+    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
+                                            const std::string& fn);
+    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
+                                            const char *fn);
 
     GraphWriter(GraphWriter& other)
@@ -1519,6 +1512,7 @@
   /// \relates GraphWriter
   template <typename Graph>
-  GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph) {
-    GraphWriter<Graph> tmp(os, graph);
+  GraphWriter<Graph> graphWriter(const Graph& graph,
+                                 std::ostream& os = std::cout) {
+    GraphWriter<Graph> tmp(graph, os);
     return tmp;
   }
@@ -1529,6 +1523,6 @@
   /// \relates GraphWriter
   template <typename Graph>
-  GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph) {
-    GraphWriter<Graph> tmp(fn, graph);
+  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
+    GraphWriter<Graph> tmp(graph, fn);
     return tmp;
   }
@@ -1539,6 +1533,6 @@
   /// \relates GraphWriter
   template <typename Graph>
-  GraphWriter<Graph> graphWriter(const char* fn, const Graph& graph) {
-    GraphWriter<Graph> tmp(fn, graph);
+  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
+    GraphWriter<Graph> tmp(graph, fn);
     return tmp;
   }
@@ -1585,7 +1579,5 @@
     /// Construct a section writer, which writes into the given file.
     SectionWriter(const std::string& fn)
-      : _os(new std::ofstream(fn.c_str())), local_os(true) {
-      if (!(*_os)) throw IoError("Cannot write file", fn);
-    }
+      : _os(new std::ofstream(fn.c_str())), local_os(true) {}
 
     /// \brief Constructor
@@ -1593,7 +1585,5 @@
     /// Construct a section writer, which writes into the given file.
     SectionWriter(const char* fn)
-      : _os(new std::ofstream(fn)), local_os(true) {
-      if (!(*_os)) throw IoError("Cannot write file", fn);
-    }
+      : _os(new std::ofstream(fn)), local_os(true) {}
 
     /// \brief Destructor
