Open file only when necessary.  Part of issue #123

This change is to make sure that we only open the file whose
language we are trying to figure out only when it is really
necessary.  In addition, code that supports templates (identified
by their extension .in) has been moved to execute before the code
that looks inside the files.  All unit tests pass.

Warning: I removed a piece of code commented thusly:

  This is needed for backward compatibility about #line directive
  behavior.

I do not know what this is about, either this is no longer
applicable or we need another unit test