in reply to utf-8 bytes dropped when printing to a file
This is a "it might change something" suggestion only. Change your binmode statement to
binmode($gOutputFileObj, ":raw:utf8"); [download]