startcode = """ DIRA HUB long = 0 OUTA PIN 0..31 LOW """ def spintobasic(filename): global startcode data = open(filename).read() data = data.split("\n") out = "" for d in data: if d[0] == " ": out += d[2:].replace(":=", "=") + "\n" else: pass return startcode+out if __name__ == "__main__": while 1: In = input("Enter filename to compile ") Out = input("Enter filename to output to ") open(Out, "w").write(spintobasic(In))