I had the same problem and used low level functions (fopen(),fget() etc.) to copy the file byte by byte - except of the unwanted at the end of the file - to a new file.
In VFP 6 you can build your result into a string variable and use STRTOFILE() to write the string content to a file. That function won't put any unwanted characters to your file.
I've acquired quite a taste for a well-made mistake... [Fiona Apple]