Writing to UTF txt file work a bit incorrect

Comments should be added.