Skip to content
Advertisement

post output to new line of text file everytime

everytime i run my code it overwrites to first line of output.txt. How can i make it so it writes to a new line every time?

JavaScript

Advertisement

Answer

This is happening because you are reopening your file in “w” mode for each row, which will overwrite your file. You can open the file outside of the for loop to avoid this behaviour:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement