##### SUMMARY
With Ansible 2.8.4 the following task worked successfully:

```
- name: "Configure index-url path."
  lineinfile:
    path: "{{ pydistutils_cfg_path }}"
    insertafter: "\\[easy_install\\]"
    regexp: "^\\s*index-url\\s+=.*$"
    line: "index-url = {{ nexus_pypi }}"
```

as soon as systems started install Ansible 2.8.6 and attempting to run the same task we started seeing errors like:

```
TASK [install_python : Configure index-url path.] ******************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: IndexError: list index out of range
fatal: [localhost]: FAILED! => {
    "changed": false,
    "rc": 1
}

MSG:

MODULE FAILURE
See stdout/stderr for the exact error


MODULE_STDERR:

Traceback (most recent call last):
  File "/home/testu18/.ansible/tmp/ansible-tmp-1571405045.44-114822878223722/AnsiballZ_lineinfile.py", line 114, in <module>
    _ansiballz_main()
  File "/home/testu18/.ansible/tmp/ansible-tmp-1571405045.44-114822878223722/AnsiballZ_lineinfile.py", line 106, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/testu18/.ansible/tmp/ansible-tmp-1571405045.44-114822878223722/AnsiballZ_lineinfile.py", line 49, in invoke_module
    imp.load_module('__main__', mod, module, MOD_DESC)
  File "/usr/lib/python3.6/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "/usr/lib/python3.6/imp.py", line 170, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 618, in _exec
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/tmp/ansible_lineinfile_payload_iwtwv4dj/__main__.py", line 567, in <module>
  File "/tmp/ansible_lineinfile_payload_iwtwv4dj/__main__.py", line 558, in main
  File "/tmp/ansible_lineinfile_payload_iwtwv4dj/__main__.py", line 413, in present
IndexError: list index out of range
```

These look very similar to the #63077 but not quite the same and in a different module.

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
lineinfile

##### ANSIBLE VERSION
```
testu18@testu18:~$ ansible --version
ansible 2.8.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/testu18/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15+ (default, Oct  7 2019, 17:39:04) [GCC 7.4.0]
```

##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```
testu18@testu18:~$ ansible-config dump --only-changed
testu18@testu18:~$
```

##### OS / ENVIRONMENT
Ubuntu 18.04 and Mac os 10.14.6


##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
---
- hosts: localhost
  tasks:
    - lineinfile:
        path: "/tmp/somefile"
        line: "[easy_install]"
        create: yes

    - lineinfile:
        path: "/tmp/somefile"
        insertafter: "\\[easy_install\\]"
        regexp: "^\\s*index-url\\s+=.*$"
        line: "index-url = https://example.org"

```

##### EXPECTED RESULTS
```
IT-USA-25903:test csalch$ ansible-playbook test_playbook.yml
 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


PLAY [localhost] *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [lineinfile] ********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
changed: [localhost]

TASK [lineinfile] ********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP ***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
```

##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes -->
```
testu18@testu18:~$ ansible-playbook ./test_playbook.yml -vvvv
ansible-playbook 2.8.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/testu18/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.15+ (default, Oct  7 2019, 17:39:04) [GCC 7.4.0]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/default.pyc

PLAYBOOK: test_playbook.yml **********************************************************************************************************************************************************************************************************************************************************************************************************************************************
Positional arguments: ./test_playbook.yml
become_method: sudo
inventory: (u'/etc/ansible/hosts',)
forks: 5
tags: (u'all',)
verbosity: 4
connection: smart
timeout: 10
1 plays in ./test_playbook.yml

PLAY [localhost] *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************************************************************************************************************************************************************************************************************************
task path: /home/testu18/test_playbook.yml:2
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: testu18
<127.0.0.1> EXEC /bin/sh -c 'echo ~testu18 && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/testu18/.ansible/tmp/ansible-tmp-1571406272.54-212983197612789 `" && echo ansible-tmp-1571406272.54-212983197612789="` echo /home/testu18/.ansible/tmp/ansible-tmp-1571406272.54-212983197612789 `" ) && sleep 0'
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/system/setup.py
<127.0.0.1> PUT /home/testu18/.ansible/tmp/ansible-local-11042z9TmO6/tmpkcGtMZ TO /home/testu18/.ansible/tmp/ansible-tmp-1571406272.54-212983197612789/AnsiballZ_setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/testu18/.ansible/tmp/ansible-tmp-1571406272.54-212983197612789/ /home/testu18/.ansible/tmp/ansible-tmp-1571406272.54-212983197612789/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /home/testu18/.ansible/tmp/ansible-tmp-1571406272.54-212983197612789/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/testu18/.ansible/tmp/ansible-tmp-1571406272.54-212983197612789/ > /dev/null 2>&1 && sleep 0'
ok: [localhost]
META: ran handlers

TASK [lineinfile] ********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
task path: /home/testu18/test_playbook.yml:4
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: testu18
<127.0.0.1> EXEC /bin/sh -c 'echo ~testu18 && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/testu18/.ansible/tmp/ansible-tmp-1571406273.37-22574126030449 `" && echo ansible-tmp-1571406273.37-22574126030449="` echo /home/testu18/.ansible/tmp/ansible-tmp-1571406273.37-22574126030449 `" ) && sleep 0'
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/files/lineinfile.py
<127.0.0.1> PUT /home/testu18/.ansible/tmp/ansible-local-11042z9TmO6/tmp_GotGN TO /home/testu18/.ansible/tmp/ansible-tmp-1571406273.37-22574126030449/AnsiballZ_lineinfile.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/testu18/.ansible/tmp/ansible-tmp-1571406273.37-22574126030449/ /home/testu18/.ansible/tmp/ansible-tmp-1571406273.37-22574126030449/AnsiballZ_lineinfile.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /home/testu18/.ansible/tmp/ansible-tmp-1571406273.37-22574126030449/AnsiballZ_lineinfile.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/testu18/.ansible/tmp/ansible-tmp-1571406273.37-22574126030449/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => {
    "backup": "",
    "changed": false,
    "diff": [
        {
            "after": "",
            "after_header": "/tmp/somefile (content)",
            "before": "",
            "before_header": "/tmp/somefile (content)"
        },
        {
            "after_header": "/tmp/somefile (file attributes)",
            "before_header": "/tmp/somefile (file attributes)"
        }
    ],
    "invocation": {
        "module_args": {
            "attributes": null,
            "backrefs": false,
            "backup": false,
            "content": null,
            "create": true,
            "delimiter": null,
            "directory_mode": null,
            "firstmatch": false,
            "follow": false,
            "force": null,
            "group": null,
            "insertafter": null,
            "insertbefore": null,
            "line": "[easy_install]",
            "mode": null,
            "owner": null,
            "path": "/tmp/somefile",
            "regexp": null,
            "remote_src": null,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": null,
            "state": "present",
            "unsafe_writes": null,
            "validate": null
        }
    },
    "msg": ""
}

TASK [lineinfile] ********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
task path: /home/testu18/test_playbook.yml:9
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: testu18
<127.0.0.1> EXEC /bin/sh -c 'echo ~testu18 && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258 `" && echo ansible-tmp-1571406273.68-75225899370258="` echo /home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258 `" ) && sleep 0'
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/files/lineinfile.py
<127.0.0.1> PUT /home/testu18/.ansible/tmp/ansible-local-11042z9TmO6/tmp34bPPv TO /home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258/AnsiballZ_lineinfile.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258/ /home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258/AnsiballZ_lineinfile.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258/AnsiballZ_lineinfile.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258/AnsiballZ_lineinfile.py", line 114, in <module>
    _ansiballz_main()
  File "/home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258/AnsiballZ_lineinfile.py", line 106, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258/AnsiballZ_lineinfile.py", line 49, in invoke_module
    imp.load_module('__main__', mod, module, MOD_DESC)
  File "/tmp/ansible_lineinfile_payload_BHn2mK/__main__.py", line 567, in <module>
  File "/tmp/ansible_lineinfile_payload_BHn2mK/__main__.py", line 558, in main
  File "/tmp/ansible_lineinfile_payload_BHn2mK/__main__.py", line 413, in present
IndexError: list index out of range

fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258/AnsiballZ_lineinfile.py\", line 114, in <module>\n    _ansiballz_main()\n  File \"/home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258/AnsiballZ_lineinfile.py\", line 106, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/testu18/.ansible/tmp/ansible-tmp-1571406273.68-75225899370258/AnsiballZ_lineinfile.py\", line 49, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_lineinfile_payload_BHn2mK/__main__.py\", line 567, in <module>\n  File \"/tmp/ansible_lineinfile_payload_BHn2mK/__main__.py\", line 558, in main\n  File \"/tmp/ansible_lineinfile_payload_BHn2mK/__main__.py\", line 413, in present\nIndexError: list index out of range\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

PLAY RECAP ***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
localhost
```

module = AnsibleModule(
        argument_spec=dict(
            path=dict(type='path', required=True, aliases=['dest', 'destfile', 'name']),
            state=dict(type='str', default='present', choices=['absent', 'present']),
            regexp=dict(type='str', aliases=['regex']),
            line=dict(type='str', aliases=['value']),
            insertafter=dict(type='str'),
            insertbefore=dict(type='str'),
            backrefs=dict(type='bool', default=False),
            create=dict(type='bool', default=False),
            backup=dict(type='bool', default=False),
            firstmatch=dict(type='bool', default=False),
            validate=dict(type='str'),
        ),
        mutually_exclusive=[['insertbefore', 'insertafter']],
        add_file_common_args=True,
        supports_check_mode=True,
    )
    params = module.params
    create = params['create']
    backup = params['backup']
    backrefs = params['backrefs']
    path = params['path']