"Hello world!" in Prolog
Why fail at all? Isn't success better than failure? A shorter version is thus:

main :- writeln('Hello world!').


Also, why even have side effects? Isn't a declarative solution much better:

message('Hello World').


This way, you can also reason about the message within the program itself. This is not possible if it only appears as output on the terminal. You can ask on the toplevel whether there is any message:

?- message(M).
M = 'Hello World'.


File endings and shebang-lines are technicalities that are pretty unrelated to the program itself. A Prolog program that is intended as a shell script will often have an initialization/1 directive somewhere in the file, like:

:- initialization(run).

This is a standardised feature, whereas placing arbitrary queries in the file is not.