Enhanced load_header_data to handle file objects, and ".gz" files.