'How to append to a file using PyCharm [closed]

Below is the code I'm using to input data into a file using pycharm, however, after the code executes the file has not changed and I know it works as I have copied it from a python scratch file and appended a different .txt file in scratch and it works. It just seems to be that the code doesn't work when in the actual project but works as a scratch, any solutions?

def add_emp():

    while True:
        name = input('Please Enter Employee Full Name: ')
        if all(name.isalpha() or name.isspace() for name in name):
            break
        print ('Invalid Name')
    while True:
        age = (input('Please Enter Employee Age: '))
        if age.isnumeric():
            break
        print ('Incorrect Value Entered')
    while True:
        position = input('Please Enter Employee Position: ')
        if position.isalpha():
            break
        print ('Invalid Position')
    while True:
        salary = (input('Please Enter Employee Salary: £'))
        if salary.isnumeric():
            break
        print ('Incorrect Value Entered')
    while True:
        years = (input('Please Enter Years Employed: '))
        if years.isnumeric():
            break
        print ('Incorrect Value Entered')
    print('\nData Entered:')
    print(name, age, position, salary, years, sep=', ')
    return name, age, position, salary, years


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source