Downloads - move file writing code out to new class

Also, use similar class when doing non-segment downloads. Verify size in both cases.
Retry request if it's truncated.
Handle re-init right.