Improve error handling and detect no-filetype files