Change fs.truncate to act like truncate(2) and extend the file, also.