Don't return null when no data, instead throw an IOException
Rearrange code