diff --git a/src/MA/Dot.hs b/src/MA/Dot.hs
index 5fbd4a39e6f9a2fc1f8587cb0bf876809e519aae..60e23d8288f34dd090116542a68def56ad87be07 100644
--- a/src/MA/Dot.hs
+++ b/src/MA/Dot.hs
@@ -1,5 +1,6 @@
 module MA.Dot
   ( printDot
+  , writeDot
   ) where
 
 import           Data.Semigroup
@@ -23,6 +24,9 @@ import           MA.PrettyShow
 printDot :: (PrettyShow label, PrettyShow h1) => SymbolTable -> Encoding label (Sorted h1) -> IO ()
 printDot symbolTable = LazyIO.putStr . Build.toLazyText . dot symbolTable
 
+writeDot :: (PrettyShow label, PrettyShow h1) => FilePath -> SymbolTable -> Encoding label (Sorted h1) -> IO ()
+writeDot file symbolTable = LazyIO.writeFile file . Build.toLazyText . dot symbolTable
+
 dot :: (PrettyShow label, PrettyShow h1) => SymbolTable -> Encoding label (Sorted h1) -> Builder
 dot symbolTable encoding =
   "digraph {\n" <> nodes symbolTable (Encoding.structure encoding) <>
diff --git a/src/main/Main.hs b/src/main/Main.hs
index ec27346d99180e7c1da73864b0d11a60b4ab6bba..aae63a7afe4fe671d36b3a876e1d8b85aaff705d 100644
--- a/src/main/Main.hs
+++ b/src/main/Main.hs
@@ -115,6 +115,7 @@ refineOptions = do
 
 data DotOptions = DotOptions
   { dotInputFile :: Maybe FilePath
+  , dotOutputFile :: Maybe FilePath
   }
 
 dotOptions :: Parser DotOptions
@@ -129,7 +130,16 @@ dotOptions = do
             \See the \"help\" command for a description of available syntax." <>
           value "-" <>
           showDefault))
-  pure DotOptions{..}
+  dotOutputFile <-
+    optional
+      (argument
+         str
+         (metavar "OUTPUT_FILE" <>
+          help
+            "Name of the file to print the output to or \"-\" for standard output." <>
+          value "-" <>
+          showDefault))
+  pure DotOptions {..}
 
 functorReader :: ReadM (FunctorExpression SomeFunctor Sort)
 functorReader = eitherReader (\input -> parseFunctor input (T.pack input))
@@ -263,7 +273,10 @@ main = do
           Left err -> hPutStrLn stderr err >> exitFailure
           Right res -> evaluate $ res
 
-      printDot symbolTable encoding
+      case dotOutputFile r of
+        Nothing -> printDot symbolTable encoding
+        Just "-" -> printDot symbolTable encoding
+        Just file -> writeDot file symbolTable encoding
 
 printHelp :: HelpCommand -> IO ()
 printHelp HelpListFunctors =