write to file in main