fix formatting errors
fix bugs with filename parsing
more informative message when file exists