import time


def remove_duplicates(file):
    """Removes duplicate lines from a file.

    Parameters:
        file (string): The name of the file to clean up.
    """
    start_time = time.time()
    articles = set()                #Create a set object.
    lines_removed = 0
    with open(file, 'r') as fin:
        lines = fin.readlines()     #Read in the lines of the file.
    with open(file, 'w') as fout:
        for line in lines:
            n = len(articles)
            articles.add(line)      #Try to add each line to the set.
            if len(articles) != n:
                fout.write(line)    #If the line was added, write it to the file.
            else:
                lines_removed += 1  #Otherwise increment the count of lines removed.
    print(lines_removed, "duplicate lines removed in", time.time()-start_time, "seconds.")
    return lines_removed