Added an option to output the network to a file