updated file.write even better.
updated file saving mechanism