Also, you would need a visa to leave the airport and enter Egypt. You don't need a visa for your connection. The visa needs to be obtained in advance, so you'd be sleeping in the airport if you change to the later flight. Some countries also have a limit to connection time (for example, Thailand limits it to 12 hours) so if Egypt has similar regulations, you can get into trouble with the authorities for overstaying without a visa, and a misconnect did not occur.