From d496e1a7db300d94a18f5e35681c5e99eefd9159 Mon Sep 17 00:00:00 2001
From: Chuck Smith <csmit223@nd.edu>
Date: Mon, 15 Jul 2024 07:32:40 -0400
Subject: [PATCH] Update script

---
 src/update_banner.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/update_banner.py b/src/update_banner.py
index 93736f5..bfa70f2 100644
--- a/src/update_banner.py
+++ b/src/update_banner.py
@@ -1,11 +1,17 @@
 import re
+import os
+
+# Set the correct path to the README.md file
+script_dir = os.path.dirname(__file__)  # Get the directory where the script is located
+root_dir = os.path.join(script_dir, '..')  # Move up to the root directory
+readme_path = os.path.join(root_dir, 'README.md')  # Path to the README.md in the root
 
 # Load the README file
-with open('README.md', 'r') as file:
+with open(readme_path, 'r', encoding='utf-8') as file:
     readme_contents = file.read()
 
 # Count the list items
-list_count = len(re.findall(r'^\s*[-*]\s', readme_contents, re.MULTILINE))
+list_count = len(re.findall(r'^\s*-\s', readme_contents, re.MULTILINE))
 
 # Define the new banner message
 new_banner = f'## Current List Count: {list_count}'
@@ -14,5 +20,5 @@ new_banner = f'## Current List Count: {list_count}'
 new_readme_contents = re.sub(r'## Current List Count: \d+', new_banner, readme_contents)
 
 # Save the changes back to README.md
-with open('README.md', 'w') as file:
+with open(readme_path, 'w', encoding='utf-8') as file:
     file.write(new_readme_contents)