minor cleaning: try/except on file and better printing of output