Implementing a function to write the file from the states machines.
Implementing an iterator function for the Events.