I gave a try with a simple file and it works fine.
You truncate to 0, means your file will be empty afterwards.
if size, 0 in your case, is greater than the files length then the behavior is undefined. Means you got to have some content in your file. Do you have content in your file?
Re: problems with truncate function
Replies are listed 'Best First'.