Added additional error handling in processDir and processFile. Also made processDir bale out early if output format is invalid.