in reply to empty a file
Why don't you simply open the file in non-append mode? you'd get the same result as truncate plus append.