Q:

How to check if a text file has gotten bigger?

My idea was to create a script where I run multiple names from a list and then compare if it is in a old_list. If it's not in the list then we print out the name or call a function. Otherwise if it's not in the list, then I just wait 5-15 sec and check again if anything got added.
However my problem right now is that I have a list with random names:
names.txt
Craig  
Rebekah  
Zina  
Stella  
Zachary  
Ila  
Delsie  
Mauro  
Alba  
Antoniette
.... more

Using this script:
def script():

    old_list = []
    old_names_list = [line.rstrip('\n') for line in open('names.txt')]

    while True:
        new_names_list = [line.rstrip('\n') for line in open('newnames.txt')]

        #if new name added to the list, then we call a random function,
        #for example: def hello() or we can just print out the name
        #and we continue to do the below.
        for names in old_names_list:

            if names not in old_list:
                print(names)
                #Call a random function etc def hello():
                old_list.append(names)

        else:
            randomtime = random.randint(5, 15)
            print('No new names fouund! - retrying in {} secs'.format(randomtime))
            time.sleep(randomtime)

newnames.txt
Rebekah  
Zina  
Stella  

Right now it does print out all the names in the list and then adds it into old_list and for the next search in the for loop it won't print out the name since it is inside the old_list. However what I want to do is that it should check new_names_list if it has added a new name in the list. If it has, it should search if the name is inside the names.txt and then print out the name that got added.
Output:
Prints out all the names and continue the while True loop.

*Adding Craig to newnames.txt*

print("Found Craig in the old_list!")

continue to search if new names got added.

A:

Is this what you want?
It loops forever, printing all the names as it finds them.
def script():
    old_names_list = [line.rstrip('\n') for line in open('names.txt')]
    while True:
        new_names_list = [line.rstrip('\n') for line in open('newnames.txt')]

        if not new_names_list == old_names_list: #if there is a change
            hell() #call that function
            for i in new_names_list:
                if not i in old_names_list:
                    print(i)
            old_names_list = new_names_list

        else: #no change
            print("no change")
            time.sleep(5)

