/UPDATED previous used stream.available which is unreliable (as pointed out in the comments — thanks inteist).