added method to reread the written file (as yet untested)
misc improvements
updated to use input/output/mapping files from cmd line