def json_append(filename, entry):
    """
    This function incrementally add entries to a json file
    while keeping the format correct

    Parameters
    ----------
    filename: str
        the name of the JSON file
    entry:
        the new entry to append
    """
    import json
    with open(filename, 'at') as f:
        if f.tell() == 0:
            json.dump([entry], f, indent=0)
        else:
            f.seek(f.tell() - 2, 0)
            f.truncate()
            f.write(',\n')
            json.dump(entry, f, indent=0)
            f.write('\n]')
