Add validation for generated file. Fixes #1