added check for directories and adjusted error message to be like 'cat'