So I'm making a python program that allows 2 people to talk to each over. The issue I'm having is that the texts only update whenever you write something. I'm not sure if there is a solution but if someone has one I'd appreciate it. Here's my code:
import os
import filecmp
import threading
username = input("Enter a Username: ")
file = open("chat.txt","w")
file.truncate(0)
file.close()
os.system("cls")
message = ""
def writing():
global message
with open("chat.txt", "a") as g:
b = input("Send message: ")
os.system("cls")
message = username+": "+ b
g.write(message)
g.write("\n")
def reading():
os.system("cls")
with open("chat.txt", "r") as f:
for line in f:
print(line)
while 2>1:
writing()
reading()
I'm kind of new to python so I may be missing something obvious.