fix data corruption in case of partial write (#18 #38)