I have a file called fName.txt in a directory. Running the following python snippet (coming from a simulation) would add 6 numbers into 3 rows and 2 columns into the text fi
You are using 'append' mode ('a') to open your file. When this mode is specified, new text is appended to the existing file content. You're looking for the 'write' mode, that is open(filename, 'w'). This will override the file contents every time you open it.