sanify indentation to 4, wrap overlong lines, ...

also a couple of more best practices: 3-way open, lexical filehandles,
no ending whitespace, do not declare lexical variable in if condition.