having difficulties getting output to write to utf-8 encoded file