Fixed formatting issue for error detail and updated code to create user-specified directory if not present before saving results.