would write_file() be better? - also what about encoding?