added file iteration and plot/run mode to main()