# Arup Guha
# Writing to a File - Basic Example
# 4/10/2020

# For checking if a file exists.
import os.path
from os import path

if path.exists("numbers.txt"):
    print("Sorry, the file we were going to write to exists. Exit program.")

# Safe to write to file.
else:

    # How we open a file to write to.
    # Very important - make sure this file doesn't exist in the directory
    # that your python program is in.
    myFile = open("numbers.txt", "w")

    # Command to write to an output file is myFile.write(string)

    # My 10 lines.
    for i in range(20):

        # Numbers on this line go from 10*i to 10*i+9.
        for j in range(10):
            myFile.write(str(10*i+j)+"\t")

        # Go to the next line.
        myFile.write("\n")

    # Close the file.
    myFile.close()
