title: PowerShell function returns array with extra 'counter' values
body: <p>#Inside the function the arrayList has 51 items, but the function returns a 102 items arrayList
  #0 to #51 are int values 0 to 51, #51 to #101 are the expected json objects?</p>
  <pre><code>function Get-RedditTopics () {
      
      $arrayList = New-Object -TypeName &quot;System.Collections.ArrayList&quot;
      $url = 'https://www.reddit.com/r/worldnews/.json'
      $pages = 2
      
      $after = &quot;&quot;
      for ($i = 0; $i -lt $pages; $i++) {
      
          if ($i -gt 0) {
              $url = $url + &quot;?after=$after&quot;
          }
      
          $result = Invoke-RestMethod $url
      
          foreach ($item in $result.data.children) {
              $arrayList.Add($item.data)
          }
      
          $after = $result.data.after
      }
      return $arrayList #51 items, ok!
  }
  
  $redditTopics = Get-RedditTopics #function returns $arrayList with 102 items
  write-host &quot;redditTopics count: $($redditTopics.Count)&quot;
  </code></pre>