May be I don't understand something, but this happens even if the file len is bigger than size the function takes.
For example, if the file data is "abcdd", and I set its len to 3, the file data looks like that: ���
File::create() overwrites any existing file with an empty one. So even if you had a file with something in it, you always start over with an empty file. You want to open the file for writing, but not for overwriting.