I suppose a fair number of us know this:
However, for those who don't:-
If you are truncating a file, say, to $fileObject->ftruncate(0), then, it may be advisable to call $fileObject->fseek(0) first (before you call '$fileObject->ftruncate').
On inspection, I was encountering 'NULL' characters at the beginning of a, or the, file.
Hence, from what I have surmised; when 'ftruncate()' is called, the file pointer does NOT move to the beginning (or, at least, the required position) of the file.
This issue cost me a fair amount of time to figure out, so I hope it helps someone.