with open("latchedScalersTAGH.db", "w") as f: for i in range(1, 234): # The 0 is replaced by the formatted index inside the loop text = f"grecord( ao, \"TAGM:T:{i}:scaler_latch\" ) {{\n}}\n" f.write(text) print("Successfully generated 233 copies in latchedScalersTAGH.db!")