Hi @Bishop_Sankhe, welcome to the Streamlit community!
This took a little more thinking than I expected! But you should be able to do this using the following:
import streamlit as st
with open("file.txt", "r") as f:
a = f.readline() # starts as a string
a = 0 if a == "" else int(a) # check if its an empty string, otherwise should be able to cast using int()
if st.button("Click me"):
a += 1
with open("file.txt", "w") as f:
f.truncate()
f.write(f"{a}")
a