You have to append the data to the line before you write it
Like so
Code:
while (fgets(FileBuf, 255, from) != NULL) {
char *p = strchr( FileBuf, '\n' );
if ( p ) *p = '\0'; // this removes the newline
// here is where you add your data
// **** is your data, and \n is a newline
// to replace the one you just removed
strcat( FileBuf, "****\n" );
// now output the file as normal
fputs(FileBuf, to);
}
You probably want to open a new file in "w" mode.
"a" is for appending whole lines to the end of the file, not appending bits of lines to the end of each line