I checked TextIOWrapper source code and confirmed that it doesn't call encoder.write(text, finish=True) on close. Since TextIOWrapper allows random access, it is difficult to call it automatically. So please think it as just limitation rather than bug. Please use codec and binary file manually for now.