write_to_file create recursive dirs