checking the file for specified types and error handling