fix the bug of write, if offset is larger than file size, then append. if not, replace. Plus,size of buf array is always 4096, should get the real buf using write_size