I am working on a script to pull comments for a subreddit, break out the individual words, count them, and sort them. Roughly 70% of the time I get this error:

```
in `<main>': undefined method `map' for nil:NilClass (NoMethodError) Did you mean?  tap

```

About 30% of the time, the script works as intended. Why is this happening? And how would you resolve? I'm new to programming so won't be surprised if the issue is basic. Here is my code:

```
require 'net/http'
require 'rubygems'
require 'json'

# Pull json file, parse out comments
url = 'https://www.reddit.com/r/askreddit/comments.json?sort=top&t=all&limit=100'
uri = URI(url)
response = Net::HTTP.get(uri)
json = JSON.parse(response)

comments = json.dig("data", "children").map { |child| child.dig("data", "body") }

#Split words into array
words = comments.to_s.split(/[^'\w]+/)

words.delete_if { |a,_| a.length < 5}

#count and sort words
count = Hash.new(0)
words.each { |word| count.store(word, count[word]+1)}
count.delete_if { |_,b| b < 4}
sorted = count.sort_by { |word,count| count}.reverse
puts sorted

```