with open(filename, 'a+') as text_file:
    text_file.seek(os.path.getsize(filename) - len(os.linesep))
text_file.write('{},\n'.format(snapshot_name))
Writing a file in python in a key=value1,....valuen format