       else
         [match, file, name, index, original] = match
 
+        # Cannot include self as a sub-graph
+        if file is currentFile
+          throw new Error("#{currentFile} is attempting to use itself as a sub-graph")
+
         # Get the FBP of the subgraph and compile that first
-        fbp = @compileSubgraphs(@loadFile(file))
+        fbp = @compileSubgraphs(@loadFile(file), file)
 
         # Affix the name to the beginning of all components in the subgraph
         fbp = fbp.replace(@matchComponentGlobal, "#{name}.$1($2)")
 
         # Replace the graph statement with the FBP
-        string = string.replace(match, "\n#{fbp}")
+        string = string.replace(match, "\n#{fbp}\n")
 
 
   parse: (string) ->

      throw err if err

  # Compile subgraphs INTO the parent graph
  compileSubgraphs: (string) ->
    loop
      match = string.match(@matchSubgraph)


  matchInitial: new RegExp "\'(.+)\'"
  matchConnection: new RegExp "\-\>"
  matchSeparator: new RegExp "[\\s,\\n]"
  matchSubgraph: new RegExp "\n *\\'(.+)\\' *-> *GRAPH *([A-Za-z\\.]+)\\(Graph\\) *\n"

  constructor: ->
    @lastElement = null
