Save file , set length=0 before writing