Added some error checking for empty files