#Copy the input file to the output file, but
#does NOT include comments!
def filterFile(fileIn, fileOut):
    #Open fileIn, and fileOut
    fIn = open(fileIn, "r")
    fOut = open(fileOut, "w")

    line = fIn.readline()
    while line  != "":
        
        indexOfHash = line.find("#")
        if indexOfHash == -1:
            fOut.write(line)
        else:
            codePart = line[0:indexOfHash]
            fOut.write(codePart + "\n")
            
        line = fIn.readline()

    fIn.close()
    fOut.close()
    
filterFile("canvas_demo.py", "nocomments.py")
print("All done!")