My code is stuck in a infinity loop - C#