Improve FileTransfer.writeToStream()

let's use the standard idiom for Input- to OutputStream transfers. This
also avoids an initial no-op on the first write, when the count is '0'.

Also fixes a bug when the size of file/stream transferred is '0' (which
is perfectly fine and possible).