add step 6 to write text file