It seems I am not allowed to write the 4bytes header separately. It's overwritten by 4 zeroes at the next write.