Question: I am trying to create a regular expression to separate each word from `.` (dot) in JavaScript.

```
function myFunction() {
  var url = "in.k1.k2.k3.k4.com"
  var result
  var match
  if (match = url.match(/^[^\.]+\.(.+\..+)$/)) {
    console.log(match);
  }
}

```

Actual result is:

```
match[0] : in.k1.k2.k3.k4.com
match[1] : k1.k2.k3.k4.com

```

Expected result is:

```
match[0] : in.k1.k2.k3.k4.com
match[1] : k1.k2.k3.k4.com
match[2] : k2.k3.k4.com
match[3] : k3.k4.com
match[4] : k4.com

```

Please help me to create perfect regular expression.

Answer: 
In order to store more than one JSON record, use an array, as when loading you can just load JSON types (an an array is the ideal JSON type you're looking for for that use case).

In that case, to read all scores:

```py
scores = []
with open ("score.json") as json_data:
    scores = json.load(json_data)

```

But most important, to write them to a file:

```py
scores.append(score)
json_dump = json.dumps(scores)
f = open("score.json","w")
f.write(json_dump)
f.close()    

```

**Update**
The last code can also be written using `json.dump`:

```py
scores.append(score)
f = open("score.json","w")
json.dump(scores, f)
f.write(json_dump)
f.close()    

```
You can read the file line by line, every line will contain a valid JSON object:

```
with open('score.json') as fp:
    for line in fp:
        data = json.loads(line)
        # do something with data

```

Or if you need everything in one object:

```
with open('score.json') as fp:
    data = []
    for line in fp:
        data.append(json.loads(line))

```