Fixed file writing issue where one character was being removed