Add file name to failure message to help identifying errors.
Omit empty lines in text output.
Rename variable to avoid confusion.