Python; using a loop to write numbers to a text. Using a loop to read them

I am trying to use a loop to write randomly generated numbers to a text document. Then, using a different program, I need to use a loop to read the numbers. The first program needs to output the numbers in the SAME LINE, the second program needs to output them in DIFFERENT LINES (their own, one per line) Here is what I have: