Fix a small bug, check for file, not directory