I don't know I got your question or not, but if you want to read a file and write it at the same time, you may like to check out This
But from my experience if you use the same file to write and read datas all the data will be erased and that might be trouble some in future, ergo you can simply make another file in the same directory and have some code like this:
original_file= open('test.txt','r') # r when we only wanna read file
revised_file = open('test1.txt','w') # w when u wanna write sth on the file
for aline in original_file:
revised_file.write('I am carl wei.\n' ) # for writing your new data
original_file.close()
revised_file.close()