Fixed key error with output saving