diff --git a/src/main/scala/leon/CallGraph.scala b/src/main/scala/leon/CallGraph.scala
index eaff99e67ac428280d24bc6fe9f54b4e5d54c150..a0455a3d3db0c05b4434fc165e12704c15cd9afe 100644
--- a/src/main/scala/leon/CallGraph.scala
+++ b/src/main/scala/leon/CallGraph.scala
@@ -213,6 +213,15 @@ class CallGraph(val program: Program) {
     res
   }
 
+  def writeDotFile(filename: String) {
+    import java.io.FileWriter
+    import java.io.BufferedWriter
+    val fstream = new FileWriter(filename)
+    val out = new BufferedWriter(fstream)
+    out.write(toDotString)
+    out.close
+  }
+
   //def analyse(program: Program) {
   //  z3Solver.setProgram(program)
   //  reporter.info("Running test generation")
diff --git a/src/main/scala/leon/TestGeneration.scala b/src/main/scala/leon/TestGeneration.scala
index a469ee54c502ee2005924a9a66c9ae34f0595d28..f78d4fd6afd23a13498b798fb68b65bf6946a03b 100644
--- a/src/main/scala/leon/TestGeneration.scala
+++ b/src/main/scala/leon/TestGeneration.scala
@@ -17,7 +17,7 @@ class TestGeneration(reporter: Reporter) extends Analyser(reporter) {
 
   def analyse(program: Program) {
     val callGraph = new CallGraph(program)
-    println(callGraph.toDotString)
+    callGraph.writeDotFile("testgen.dot")
     callGraph.findAllPathes.foreach(path => {
       println("Path is: " + path)
       println("constraint is: " + callGraph.pathConstraint(path))