in reply to delete data from file
You can't really. I will qualify that.
If the data you wish to delete is at the end of the file then you could truncate the file, in other words you just move the position of EOF. I guess that is not the case.
You could replace the characters that should be deleted with something like 0x00, but that is not guaranteed to be ignored by the code that will read it, unless you have control over that.
The only practical way is to create a new file containing only those lines of interest, then rename it to the same name as the original.