main read loop rewritten, -SSL