The normal case is that one looks over the invention, makes a brief check for prior art, draft the application and file it in the hope of it being inventive. Examiners at the various patent offices are the experts on searching for prior art and will decide if a patent can be granted or not.
It does indeed happen that unexpected and fatal prior art comes up, wiping out the application.
This is how the system is used normally. Filing an application knowing of fatal prior art is useful only in extremely unusual cases and a grant cannot be expected anyway.