Updated to terminate malformed requests without newlines