I dont know why but with the code below everything works fine and all the text is taken out and then put back into the text file
def upgradecap():
yc = open("ycfile", 'r')
a = yc.readline()
b = yc.readline()
c = yc.readline()
d = yc.readline()
e = yc.readline()
f = yc.readline()
g = yc.readline()
h = yc.readline()
i = yc.readline()
j = yc.readline()
k = yc.readline()
cap = yc.readline()
cap = int(cap)
cap = cap + 2500
cap = str(cap)
l = yc.readline()
yc = open("ycfile", "w+")
yc.write(a)
yc.write(b)
yc.write(c)
yc.write(d)
yc.write(e)
yc.write(f)
yc.write(g)
yc.write(h)
yc.write(i)
yc.write(j)
yc.write(k)
yc.write(cap + '\n')
yc.write(l)
yc.close()
L62.configure(text=cap)
But the next line of code writes everything back to the file except from the last line of writing to the file in the second function
def upgradetrn():
yc = open("ycfile", 'r')
a = yc.readline()
b = yc.readline()
c = yc.readline()
d = yc.readline()
e = yc.readline()
f = yc.readline()
g = yc.readline()
h = yc.readline()
i = yc.readline()
j = yc.readline()
trn = yc.readline()
trn = int(trn)
trn = trn + 1
trn = str(trn)
k = yc.readline()
x = yc.readline()
yc = open("ycfile", "w+")
yc.write(a)
yc.write(b)
yc.write(c)
yc.write(d)
yc.write(e)
yc.write(f)
yc.write(g)
yc.write(h)
yc.write(i)
yc.write(j)
yc.write(trn + '\n')
yc.write(k)
yc.write(x)
yc.close()
L61.configure(text=trn)
All i am trying to do is take each line out of the text file and edit one line and then put it all back in. Does anyone know why this is happening? Thanks for any answers