Fix bug in output filename generation.