I am running my script which increments a variable by writing out a number and reading it back in. Therefor i am creating a txt file that holds the current run number.
f = open("test.txt", "r") x = int(f.readlines()[0]) #assume thet text contains one line with number 1 f.close() f = open("test.txt", "w") x += 1 f.write(str(x)) Is there any harm of doing it like that?