Fixed a bug with writing out non-ASCII characters