after a long troubleshooting, I finally understands what went wrong

This is how I created the pwd.txt file

echo "abcde" > pwd.txt

and by doing so, it generated a UTF-16 encoded file, which has the annoying habit of having invisible characters added to it at the beginning and in between the characters as well ...

Windows stuffs

Reply to this note

Please Login to reply.

Discussion

I realized all this because of the use of 'echo' in the Windows terminal

once I used Perl to write the pwd.txt file, everything went fine ... no surprise, no added extra characters

the file generated by the echo command had a BOM invisible character at the start, FF FE and 00 every second character because UTF-16 requires two code units to represent a single character.

surprise, surprise

I see, encoding issues.