Remove leading and trailing whitespace when choosing filenames. Fixes issue #401.