This whole function should go away once the actual write_file is fixed. Yeah.