Fixed bugs where strings were not written correctly