def METHOD_NAME(start_time_file, max_chunk_size, delay):
    try:
        with open(start_time_file) as f:
            date = datetime.datetime.strptime(f.read(), "%Y/%m/%d")
            logging.debug("Obtained last end time from file '%s'" % start_time_file)
    except OSError:
        date = datetime.datetime.now()
        logging.info("No state file. Starting from now.")
    current_day = date.day
    logging.debug("Starting at %s with current day %d", date, current_day)
    logging.debug("Will emit at most %d works", max_chunk_size)
    seen = set()
    rest = []
    while True:
        url = date.strftime(BASE_URL + "%Y/%m/%d.json")
        logging.debug("-- Fetching changes from %s", url)
        changes = list(requests.get(url).json())
        unseen_changes = [x for x in changes if x['id'] not in seen]
        logging.debug("%d changes fetched", len(changes))
        logging.debug(" of which %d are unseen", len(unseen_changes))
        # Fetch works for all changesets we've not seen yet. Add them
        # to the ones left over from the previous iteration.
        works = list(extract_works(unseen_changes))
        logging.debug("  in which %d have works modified.", len(works))
        logging.debug(
            "  There are %d left over works from the last iteration.", len(rest)
        )
        works += rest
        logging.debug("    Totally %d works to be emitted" % len(works))
        # Record all the ones we've already emitted for this day
        for i in (x['id'] for x in unseen_changes):
            seen.add(i)
        logging.debug("Number of Changes seen so far %d", len(list(seen)))
        # If the current day is over.
        if current_day != datetime.datetime.now().day:
            seen = set()  # Clear things seen so far
            date = datetime.datetime.now()  # Update date
            current_day = date.day
            logging.debug("Flipping the clock to %s and clearing seen changes", date)
        # If there are too many works, emit only max_chunk_size
        # works. Keep the rest for the next iteration
        if len(works) > max_chunk_size:
            logging.debug(
                "  Number of works to be emitted (%d) is more than %s",
                len(works),
                max_chunk_size,
            )
            to_be_emitted, rest = works[:max_chunk_size], works[max_chunk_size:]
            logging.debug("    Retaining %s", len(rest))
        else:
            to_be_emitted, rest = works, []
        if to_be_emitted:
            logging.debug("Emitting %d works", len(to_be_emitted))
            for i in to_be_emitted:
                print(i)
        logging.debug("Sleeping for %d seconds", delay)
        time.sleep(delay)
        with open(start_time_file, "w") as f:
            logging.debug("Writing %s to state file", date.strftime("%Y/%m/%d"))
            f.write(date.strftime("%Y/%m/%d"))