Rewrote function for reading server data to safely handle variable length input.