Hi Eli, OK, it looks like the null byte was the major problem. That resolves some mysteries like why the file looked ok in Notepad -- which presumably just deletes null bytes.
You know, I'd forgotten about this. About three or four years ago I was having a problem, and I finally noticed that the buffer contained "^@", which is a null byte, and I deleted that byte and everything was fine. But I completely forgot about that experience until now. Since a null byte has such huge consequences, one thing you might consider is displaying a message, "Your file contains null bytes," when such a file is loaded, or a string with a null byte is pasted. Anyway, thanks for all your help. It's a big relief to have this problem resolved. John