Checks that directory is valid, and outputs error otherwise.