Reformat exceptions and add blank lines at the end before closing the file