Index was out of range. How to check if list has items without triggering this error? - C#