We found that when a disk was full, samtools sort using multi-cores
would not error out as expected, but instead continue leading to
temp files of size 0.  This commit checks return code of writes
in this portion of the code and will error if writes are not
successful.