Code stuck in loop

I’m doing a “Payment machine” project, it’s supposed to have a menu with 2 options. 1st option is “Take Payment” Where you’re asked to enter card number, Payment amount, if payment amount is greater than maximum amount from external file you are prompted to enter PIN number. The inputs should be saved at an external file. Any suggestions?

def mainMenu():
  print(30 * "-", "MENU", 30 * "-")
print("1. Take Payment")
print("2. System config")

def payment():

  paymentAmount = str(input('Please enter payment amount: £'))

cardNumber = input('Enter your 16 digit card number: ')

if paymentAmount > file_contents:
  pinNumber = int(input('Enter your 4 digit PIN number: '))
file = 'paymentamount.txt'
with open(file, 'a') as f:
  f.write(paymentAmount + "\n")
f.write(cardNumber + "\n")
# # You can add your code or functions here
print("Payment Succeseful")

def config():

filepath = 'golf.txt'
with open(filepath, 'r') as f:
  # Get the entire contents of the file
file_contents =

# Remove any whitespace at the end, e.g.a newline
file_contents = file_contents.strip()

# # You can add your code or functions here

choice = input("Enter your choice [1-2]: ")

while True:
choice = input("Enter your choice [1-2]: ")
if choice == 1:
elif choice == 2:
else :
  print("Invalid choice. Enter 1-3")

A couple of observations and questions to help you narrow down the problem with your code.

  1. Have you checked the proper indentation to ensure that the lines of code belong to the right block?
  2. Do you have an error message ?
  3. The question title indicates you are running into infinite loop condition but the question is about saving to the file. Could you specify which problem you need help with?