Improve the loader a bit

Clean up the loader to open the file only once and pass the IOFile around to functions requiring it, and add a real file detection function based on its magic.
This is wrong. Constructor should accept a `&&` ref instead. (Otherwise you can silently move away a thing you didn't mean to when calling this.)