Scanner no longer overly greedy

The scanner previously captured parts of larger keys as the
intended ones, e.g. \includegraphics would get picked up by
\include
Improved output behavior around pdflatex

Flush stdout before calling pdflatex and print upon its completion.