diff --git a/hwmonDaemon.py b/hwmonDaemon.py index 3a6ab26..c985e94 100644 --- a/hwmonDaemon.py +++ b/hwmonDaemon.py @@ -783,7 +783,10 @@ class SystemHealthMonitor: # Load historical data with file locking history = [] - file_mode = 'r+' if os.path.exists(historical_file) else 'w+' + if os.path.exists(historical_file) and os.path.getsize(historical_file) > 0: + file_mode = 'r+' + else: + file_mode = 'w+' with open(historical_file, file_mode) as f: # Acquire exclusive lock