#322: properly define 'filename' outside 'if-else' block

Resolves #322.