So the code works and the connection is there but you just don't get what you want.
That is because you are communicating with the server on the raw HTTP level. The received data will begin with an HTTP response that you have to analyse.
If you don't want to do that yourself you have to use a library that does it for you (a web client library).
See also
URL redirection - Wikipedia[
^]. It explains what is happening and shows an example of such a redirection with the HTPP header and the HTML content.