Added simple main loop with signal handlers

This is for #46.


Can you please change this to write on `stderr` instead?