I understand that you have already solved your problem. However, you should be aware that I had another problem with a nearly identical program. The site would not download copyrighted material to a 'browser' they did not recognize. The downloaded file actually was an html file containing the explanation (perl still thought it was pdf.)