writing exceptions to file