Question: Write output of for loop to .txt file with additional text

I have the following code. I want to do the modify it so that:

1. The outputs of each for loop are merged in such a way that the outputs from the first loop (Es) that are also outputs of the second loop (Fs) are removed from the outputs of (Es).

2. The resulting outputs G= .... are saved to a text file, one to each line.

3. In between each output, I want to add 5 lines of text and a blank line, say

text1 text2 text3

text2 text2 text3

text3 text3 text3

text4 text4 text4

text5 text5 text5

(blank line)

so that in the text file, the format is (e.g.)

G={{1,2}};

text1 text2 text3

text2 text2 text3

text3 text3 text3

text4 text4 text4

text5 text5 text5

(blank line)

G={{1,2},{1,3}};

text1 text2 text3

text2 text2 text3

text3 text3 text3

text4 text4 text4

text5 text5 text5

(blank line)

etc.

What is the easiest way to accomplish this?

restart;
 
with(GraphTheory):
 n:= 4:
  L:= NonIsomorphicGraphs
      ( n,
        output=iterator,
        outputform=graph):
  Es:= Array
       ( [ seq
           (  Edges( L() ),
              j=1..NonIsomorphicGraphs
                   ( n,
                     output=count
                   )
           )
         ]
       ):


  M:= NonIsomorphicGraphs
      ( n-1,
        output=iterator,
        outputform=graph):
  Fs:= Array
       ( [ seq
           (  Edges( M() ),
              j=1..NonIsomorphicGraphs
                   ( n-1,
                     output=count
                   )
           )
         ]
       ):
;

numelems(Es): 
for i from 1 to numelems(Es) do G:=Es[i]:  od;
                           
numelems(Fs):
for i to numelems(Fs) do G := Fs[i]; od;
                        

Please Wait...