I have a class where all of our data is in, here I open a file by:
carIn= open("dataIn.txt","w")
carOut= open("dataUit.txt","w")
In another class I have a loop for the main program. I closed my file in the loop but it won't open again. If I close it outside the loop, the entire program crashes. This is my code:
while startScreen.getstopt() == False:
startScreen.start()
print("screen start")
screen = Screen(wereld.getIntersection())
startSimulatiion()
print("Simulatiion start:")
for x in Files.listIn:
Files.carIn.write(str(x) + "\n")
for x in Files.listOut:
Files.carOut.write(str(x) +"\n")
result= Resultaten()
Files.calculatedRatio= result.calculateRatio()
print(Files.calculatedRatio)
if screen.startScreen == True:
Files.carIn.write("\n")
Files.carIn.write("\n")
Files.carIn.write("\n")
Files.carOut.write("\n")
Files.carOut.write("\n")
Files.carOut.write("\n")
Files.carIn.close()
Files.carOut.close()