def compileLine(word, num, outfile):
    outfile.write("    for (int i = 0; i < " + num + "; i++)\n")
    outfile.write("    {\n")
    outfile.write('        printf("%s\\n", "' + word + '");\n')
    outfile.write("    }\n")

with open("pets.c", 'w') as outfile:
    outfile.write("#include <stdio.h>\n")
    outfile.write("\n")
    outfile.write("int main()\n")
    outfile.write("{\n")

    with open("pets.echo", 'r') as infile:
        for line in infile:
            word, num = line.strip().split(" ")
            compileLine(word, num, outfile)

    outfile.write("    return 0;\n")
    outfile.write("}")
