Remove unused code
Code cleanup

- Better code organization (no giant for loop in main)
- Fix some error handling
- Close files after processing with --dry-run

Fixes #7.
If no files are given, read filenames from stdin

Fixes #3.
Add a test of basic functionality