change !is_dir to is_file