I'm having issues with this code "@dataclass
class FileInfo:
    filepath: str
    hash_value: str
    atime: float
    ctime: float
    mtime: float

def hash_file(file_path):
    """Calculate the MD5 hash of a file."""
    hasher = hashlib.md5()
    try:
        with open(file_path, 'rb') as f:
            buf = f.read()
            hasher.update(buf)
        return hasher.hexdigest(), None
    except Exception as e:
        return None, f"Error hashing file {file_path}: {e}"

def hash_file_wrapper(file_path):
    hash_value, error = hash_file(file_path)
    return file_path, hash_value, error

def find_files(directory):
    """Find files of specified types in the given directory and hash them."""
    files = []
    errors = []
    most_recent_file = None
    most_recent_mtime = 0

    with concurrent.futures.ProcessPoolExecutor() as executor:
        futures = []
        for root, _, files_list in os.walk(directory):
            for file_name in files_list:
                file_path = os.path.join(root, file_name)

                if os.path.isfile(file_path) and os.path.splitext(file_name)[1] in file_types:
                    future = executor.submit(hash_file_wrapper, file_path)
                    futures.append(future)

        for future in tqdm(concurrent.futures.as_completed(futures), total=len(futures), desc="Hashing files"):
            file_path, hash_value, error = future.result()
            if hash_value:
                atime = os.path.getatime(file_path)
                ctime = os.path.getctime(file_path)
                mtime = os.path.getmtime(file_path)
                files.append(FileInfo(filepath=file_path, hash_value=hash_value, atime=atime, ctime=ctime, mtime=mtime))

                if mtime > most_recent_mtime:
                    most_recent_mtime = mtime
                    most_recent_file = file_path
            elif error:
                errors.append(error)

    return files, most_recent_file, errors

def find_duplicates(paths, most_recent_file):
    """Find duplicate files in the given directories."""
    duplicates = {}

    with concurrent.futures.ProcessPoolExecutor() as executor:
        futures = []
        for path in paths:
            for root, _, filenames in os.walk(path):
                for filename in filenames:
                    full_path = os.path.join(root, filename)
                    if os.path.splitext(filename)[1] in file_types:
                        future = executor.submit(hash_file, full_path)
                        futures.append((future, full_path))

        for future, full_path in tqdm(futures, desc="Finding duplicates"):
            hash_value, error = future.result()
            if hash_value:
                if hash_value in duplicates:
                    mtime = os.path.getmtime(full_path)
                    if mtime < os.path.getmtime(most_recent_file):
                        duplicates[hash_value].append(full_path)
                else:
                    duplicates[hash_value] = [full_path]
            elif error:
                print(error)

    return duplicates

def export_to_excel(files, duplicate_files, excel_path):
    """Export files and duplicate files to an Excel file."""
    wb = Workbook()

    # Files Sheet
    file_sheet = wb.active
    file_sheet.title = "Files"
    file_sheet.append(["Filepath", "MD5 Hash", "Access Time", "Creation Time", "Modification Time"])
    for file_info in files:
        file_sheet.append([file_info.filepath, file_info.hash_value, file_info.atime, file_info.ctime, file_info.mtime])

    # Duplicate Files Sheet
    duplicate_sheet = wb.create_sheet(title="Duplicate Files")
    duplicate_sheet.append(["Filepath", "MD5 Hash", "Access Time", "Creation Time", "Modification Time"])
    for hash_value, paths in duplicate_files.items():
        for path in paths:
            duplicate_sheet.append([path, hash_value, "", "", ""])

    # Save Excel file with error handling
    try:
        wb.save(excel_path)
        print(f"Excel file saved to: {excel_path}")
    except PermissionError as e:
        print(f"PermissionError: {e}")

def main():
    directory = directory1
    if not os.path.exists(directory):
        print("Directory does not exist.")
        return

    with tqdm(desc="Processing", total=4) as pbar:
        pbar.update(1)

        # Step 1: Find files and hash them
        files, most_recent_file, errors = find_files(directory)

        if not files:
            print("No files found in the specified directory.")
            return
        pbar.update(1)

        print("Files found:")
        for file_info in files:
            print(f"File: {file_info.filepath}, MD5 Hash: {file_info.hash_value}")

        pbar.update(1)

        # Step 2: Find duplicate files
        duplicate_files = find_duplicates([directory], most_recent_file)

        if not duplicate_files:
            print("No duplicate files found.")
        else:
            print("Duplicate files found:")
            for hash_value, paths in duplicate_files.items():
                print(f"Hash: {hash_value}, Files: {', '.join(paths)}")

        # Print counts before exporting to Excel
        print(f"Number of files found: {len(files)}")
        print(f"Number of duplicate files found: {len(duplicate_files)}")

        pbar.update(1)

        # Step 3: Export results to Excel
        export_to_excel(files, duplicate_files, excel_path)
        pbar.update(1)

if __name__ == "__main__":
    main()
" IT will only output one line in the excel file to output when we should have hundred of rows.