More safe if statement in getFilename()

refs #156