flushing file output, added comments, added params for NotReachableException