for inputFile in os.listdir(directoryPath):

    if inputFile.endswith(".vm"):

        # add path to file name
        fullPathInputFile = directoryPath + "/" + inputFile

        # create new parser object
        newParser = Parser(fullPathInputFile, newCodeWriter)

        # remove comments and extra lines
        noCommentsArray = RemoveWhitespace.removeWhiteSpaceAndComments(newParser.linesArray)

        # for debugging code: adds file name
        outputArray = []
        outputArray.append("//" + inputFile)

        #output array from my Parser
        newParserOutput = newParser.translateVMtoASM(noCommentsArray)

        # translate vm file into .asm file
        # tack on Parser output to debug code
        outputArray.extend(newParserOutput)

        #extend our master output array
        masterOutputArray.extend(outputArray)

#add array to new hack file in same path as input
with open(outFile, 'w') as outputFile:
    for line in masterOutputArray:
        outputFile.write(line + "\n")