I was trying to make the application as user friendly as possible. Therefore I thought it worthwhile checking that all the characters supplied could be used (rather than getting a system error message which may not be that good to work with).
Also, I should have said that I am working on Windows - hence the list of invalid characters I gave in the subroutine.