Improve pem file error checking

Although I am opening the pull request, it's actually based on work from a previous pull request (https://github.com/glenjarvis/ansible_tutorial/pull/66) by Alex Kleider.