Strange FSEEK and FPUTS results.

I'm using 'fseek' and 'fputs' to edit the contents of a text file.
Below is the code I'm using.
It basically searches the file for the line that contains ABCDEFGH.
It then overwrites that with ZZZZZZZZ.
It works OK except that there is a strange character inserted after the ZZZZZZZZ. (And the overwrite extends a few characters further.)
When I say strange, it appears in the text file as small black rectangle.
It doesn't want to be copy and pasted ...if that makes sense!

Let me put it this way.
Assume that the # in this line is the strange character:
1234567XXXXXX54321ZZZZZZZZ#123456789.
If I highlight that whole line, and then paste it, I only see everything up to the #. The last series of digits don't appear!
What could be the problem.
Thanks.
PS. The -81 in the 'fseek' refers to the fact that the overwrite point is 81 characters back from where the position locator is currently sitting.

filepointer1 = fopen(textfile, "r+");
while (fgets(mystring,sizeof(mystring1),filepointer1) )
{
countline = countline + 1;
pch = strstr (mystring1 ,"ABCDEFGH");
if (pch !=NULL)
{fseek ( filepointer1, -81 , SEEK_CUR );
fputs ("ZZZZZZZZ",filepointer1);
fgets (mystring2, 5, filepointer1);
break;
}
}
Make sure the string is null terminated.
Thanks for the quick reply ...

but what string would that be?
Never mind. I don't know what I thought about.
Topic archived. No new replies allowed.