Corrected logging error and added proper handling of directories in the -f option