Assuming fmt is compatible with output, your code should save data to out_name.
fmt
output
out_name
Is it not working? If so, what was the full traceback error message?