add a function to truncate a file to a specified size