Updated to write to file when run