Added check for filetype and error message