add additional error checking to ensure file and contents exist