Added Error-Checking when opening a file.