My program starts up and sometimes don't work with no seen reason

Hi, i made a program, brightness changer, that supposed to change brightness on your pc using start hour - brightness at the start - smoothness(how quick brightness will be changing) and end hour - brightness at the end - late smoothness. To create window i used ttkbootstrap and the start of program is trying to access savedData.txt (early listed variables). Everything works perfect but i have an odd issue that i have no idea where it comes from
So, the thing is i used pyinstaller to convert my python file to exe, also i managed to start it on start up(when i turn on my pc, this program starts) and still everything is ok, but sometimes brightness isn’t changing. I mean the program opens but not changing my brightness as this supposed, and it happens with no clue, just one day works pretty, and another just nah, in this situation i close it and reopen helps me. I do nothing and i get different result, maybe you have the same moment, or i missed something interesting during coding, if you know what’s that - i’ll be really grateful

And my code(I’m using Windows 10):

from concurrent.futures import thread
from ensurepip import bootstrap
import glob
from struct import pack
import threading
from turtle import left
from unittest import skip
from screen_brightness_control import get_brightness, set_brightness, fade_brightness
from time import sleep, strftime
from tkinter import *
from ttkbootstrap.constants import *
import ttkbootstrap as tb
import pystray
import PIL.Image
import threading
import ttkbootstrap.style

firstSecond = int()
firstChange = int()
secondSecond = int()
secondChange = int()
daySmoothness = int()
eveningSmoothness = int()

brightnessUp = None
dayTime = None
x = get_brightness()
currentBrightness = int(x[0])
speakerText = ""
theme = 0
anim = 0

root = tb.Window(themename="darkly")
root.title("BRIGHTNESS PROGRAM")
root.geometry("700x650")
root.iconbitmap("lightIcon.ico")

try:
    savedData = open("savedData.txt", "r")
    content = savedData.read()
    savedData.close()
    content = content.split()
    speakerText = "Savedata file found"
except:
    savedData = open("savedData.txt", "w")
    content = savedData.write("")
    savedData.close()
    speakerText = "Created saveddata file"
    
    savedData = open("savedData.txt", "r")
    content = savedData.read()
    savedData.close()
    content = content.split()

try:
    firstSecond = int(content[0])
    firstChange = int(content[1])
    secondSecond = int(content[2])
    secondChange = int(content[3])
    daySmoothness = int(content[4])
    eveningSmoothness = int(content[5])
    theme = int(content[6])
    
    if theme == 1:
        ttkbootstrap.Style("morph")
    else:
        ttkbootstrap.Style("darkly")
    sleep(1)
except:
    speakerText = "There are no prepared variables"
    sleep(1)
    
def ChangeBrightness():
        global currentBrightness
        global dayTime
        global anim
        x = get_brightness()
        currentBrightness = int(x[0])
            
        if dayTime == True:
            if currentBrightness > firstChange:
                currentBrightness -= 1
                if anim == 0:
                    anim = 1
                else:
                    anim = 0
                global speakerText
                if anim == 0:
                    speaker.config(text="Brightness-")
                else:
                    speaker.config(text="Brightness -")
                set_brightness(currentBrightness)
            elif currentBrightness < firstChange:
                currentBrightness += 1
                if anim == 0:
                    anim = 1
                else:
                    anim = 0
                if anim == 0:
                    speaker.config(text="Brightness+")
                else:
                    speaker.config(text="Brightness +")
                set_brightness(currentBrightness)
            elif currentBrightness == firstChange:
                sleep(1)
                speaker.config(text="Brightness == First Change")
        else:
            if currentBrightness > secondChange:
                currentBrightness -= 1
                if anim == 0:
                    anim = 1
                else:
                    anim = 0
                if anim == 0:
                    speaker.config(text="Brightness-")
                else:
                    speaker.config(text="Brightness -")
                set_brightness(currentBrightness)
            elif currentBrightness < secondChange:
                currentBrightness += 1
                if anim == 0:
                    anim = 1
                else:
                    anim = 0
                if anim == 0:
                    speaker.config(text="Brightness+")
                else:
                    speaker.config(text="Brightness +")
                set_brightness(currentBrightness)
            elif currentBrightness == secondChange:
                sleep(1)
                speaker.config(text="Brightness == Second Change")
                
        if dayTime == True:
            threading.Timer(daySmoothness, ChangeBrightness).start()
        elif dayTime == False:
            threading.Timer(eveningSmoothness, ChangeBrightness).start()
            
def changeTheme():
    global theme
    if theme == 1:
        ttkbootstrap.Style("darkly")
        theme = 0
    elif theme == 0:
        ttkbootstrap.Style("morph")
        theme = 1
        

def program():
    currentSecond = int(strftime("%H"))
    global dayTime
    if currentSecond >= firstSecond and currentSecond < secondSecond:
        dayTime = True
    elif currentSecond >= secondSecond or currentSecond < firstSecond:
        dayTime = False
                
    threading.Timer(60, program).start()

programT = threading.Thread(target=program)
programT.daemon = True
programT.start()

ChangeBrightnessT = threading.Thread(target=ChangeBrightness)
ChangeBrightnessT.daemon = True
ChangeBrightnessT.start()

def save():
    try:
        global firstSecond
        firstSecond = int(fsEntry.get())
        global secondSecond
        secondSecond = int(ssEntry.get())
        global firstChange
        firstChange = int(ffEntry.get())
        global secondChange
        secondChange = int(sfEntry.get())
        global daySmoothness
        daySmoothness = int(smEntry.get())
        global eveningSmoothness
        eveningSmoothness = int(smEntry2.get())
        global theme
        savedData = open("savedData.txt", "w")
        savedData.write(f"{firstSecond}\n{firstChange}\n{secondSecond}\n{secondChange}\n{daySmoothness}\n{eveningSmoothness}\n{theme}")
        savedData.close()
        global speakerText
        speaker.config(text="Saved!")
    except:
        speaker.config(text="Wrong text")
        
def restoreFromTray(icon, item):
    global trayed
    trayed = False
    root.deiconify()
    icon.stop()
    
def close(icon, item):
    icon.stop()
    root.quit()
    
def minimizeToTray():
    root.withdraw()
    image = PIL.Image.open("lightIcon.ico")
    menu = (pystray.MenuItem("Show", restoreFromTray), pystray.MenuItem("Quit", close))
    icon = pystray.Icon("BRIGHTNESS PROGRAM", image, "BP", menu)
    icon.run_detached()
    
root.protocol("WM_DELETE_WINDOW", minimizeToTray)
        
myLabel = tb.Label(text="Brightness Program", font=("Berlin Sans FB", 35), bootstyle="default")
myLabel.pack(pady=0)

speaker = tb.Label(text=f"{speakerText}", font=("Berlin Sans FB", 15), bootstyle="default")
speaker.pack(pady=0)

fsLabel = tb.Label(text="First time", font=("Berlin Sans FB", 10), bootstyle="default")
fsLabel.pack()

fsEntry = tb.Entry(root, bootstyle="info", font=("Berlin Sans FB", 10), foreground="light blue", width=4)
fsEntry.pack(pady=5)

fsEntry.insert(0, firstSecond)

ffLabel = tb.Label(text="First force", font=("Berlin Sans FB", 10), bootstyle="default")
ffLabel.pack()

ffEntry = tb.Entry(root, bootstyle="info", font=("Berlin Sans FB", 10), foreground="light blue", width=3)
ffEntry.pack(pady=5)

ffEntry.insert(0, firstChange)

smLabel = tb.Label(text="Day Smoothness", font=("Berlin Sans FB", 10), bootstyle="default")
smLabel.pack()

smEntry = tb.Entry(root, bootstyle="info", font=("Berlin Sans FB", 12), foreground="light blue", width=3)
smEntry.pack(pady=5)

smEntry.insert(0, daySmoothness)

myLabel2 = tb.Label(text="|", font=("Berlin Sans FB", 10), bootstyle="default")
myLabel2.pack(padx=5)

ssLabel = tb.Label(text="Second time", font=("Berlin Sans FB", 10), bootstyle="default")
ssLabel.pack()

ssEntry = tb.Entry(root, bootstyle="info", font=("Berlin Sans FB", 10), foreground="light blue", width=4)
ssEntry.pack(pady=5)

ssEntry.insert(0, secondSecond)

sfLabel = tb.Label(text="Second force", font=("Berlin Sans FB", 10), bootstyle="default")
sfLabel.pack()

sfEntry = tb.Entry(root, bootstyle="info", font=("Berlin Sans FB", 10), foreground="light blue", width=3)
sfEntry.pack(pady=5)

sfEntry.insert(0, secondChange)

smLabel2 = tb.Label(text="Evening Smoothness", font=("Berlin Sans FB", 10), bootstyle="default")
smLabel2.pack()

smEntry2 = tb.Entry(root, bootstyle="info", font=("Berlin Sans FB", 12), foreground="light blue", width=3)
smEntry2.pack(pady=5)

smEntry2.insert(0, eveningSmoothness)

myButton = tb.Button(text="SAVE", bootstyle="primary, outline", command=save)
myButton.pack(pady=20)

themeButton = tb.Button(text="☀", bootstyle="primary, outline", command=changeTheme)
themeButton.pack(side=LEFT, padx=10)

root.mainloop()