diff --git a/add_trailing_comma.py b/add_trailing_comma.py
index 9efea83..736fa7d 100644
--- a/add_trailing_comma.py
+++ b/add_trailing_comma.py
@@ -179,13 +179,16 @@ def _fix_call(call, i, tokens):
     #
     #     func_name(arg, arg, arg)
     #              ^ outer paren
+    brace_start, brace_end = '(', ')'
     first_paren = None
     paren_stack = []
     for i in range(i, len(tokens)):
         token = tokens[i]
-        if token.src == '(':
+        if token.src == brace_start:
             paren_stack.append(i)
-        elif token.src == ')':
+        # the ast lies to us about the beginning of parenthesized functions.
+        # See #3. (why we make sure there's something to pop here)
+        elif token.src == brace_end and paren_stack:
             paren_stack.pop()
 
         if (token.line, token.utf8_byte_offset) in call.arg_offsets:
@@ -194,7 +197,7 @@ def _fix_call(call, i, tokens):
     else:
         raise AssertionError('Past end?')
 
-    _fix_inner('(', ')', first_paren, tokens)
+    _fix_inner(brace_start, brace_end, first_paren, tokens)
 
 
 def _fix_literal(literal, i, tokens):

"IndexError: pop from empty list" when processing valid file
(Wasn't sure how to describe this scenario better, sorry for the lame title.)

Here's a fairly minimal example:

```python
(
    a
).thing(b)
```

Produces an error when processing with add-trailing-comma v0.2.0:

```python
Traceback (most recent call last):
  File "/nail/home/ckuehl/.pre-commit/repojgy42wl2/py_env-python2.7/bin/add-trailing-comma", line 9, in <module>
    load_entry_point('add-trailing-comma==0.2.0', 'console_scripts', 'add-trailing-comma')()
  File "/nail/home/ckuehl/.pre-commit/repojgy42wl2/py_env-python2.7/local/lib/python2.7/site-packages/add_trailing_comma.py", line 269, in main
    ret |= fix_file(filename, args)
  File "/nail/home/ckuehl/.pre-commit/repojgy42wl2/py_env-python2.7/local/lib/python2.7/site-packages/add_trailing_comma.py", line 249, in fix_file
    contents_text = _fix_commas(contents_text, args.py35_plus)
  File "/nail/home/ckuehl/.pre-commit/repojgy42wl2/py_env-python2.7/local/lib/python2.7/site-packages/add_trailing_comma.py", line 232, in _fix_commas
    _fix_call(call, i, tokens)
  File "/nail/home/ckuehl/.pre-commit/repojgy42wl2/py_env-python2.7/local/lib/python2.7/site-packages/add_trailing_comma.py", line 189, in _fix_call
    paren_stack.pop()
IndexError: pop from empty list
```
diff --git a/tests/add_trailing_comma_test.py b/tests/add_trailing_comma_test.py
index ddc0bc3..5d1c798 100644
--- a/tests/add_trailing_comma_test.py
+++ b/tests/add_trailing_comma_test.py
@@ -42,6 +42,10 @@ xfailif_lt_py35 = pytest.mark.xfail(sys.version_info < (3, 5), reason='py35+')
         'x((\n'
         '    1,\n'
         '))',
+        # regression test for #3
+        '(\n'
+        '    a\n'
+        ').f(b)',
     ),
 )
 def test_fix_calls_noops(src):

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest
3.6
requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
-e git+https://github.com/asottile/add-trailing-comma.git@9ce37f20c644269487c52030912e20a75cc191c1#egg=add_trailing_comma
attrs==22.2.0
certifi==2021.5.30
cfgv==3.3.1
coverage==6.2
distlib==0.3.9
filelock==3.4.1
flake8==5.0.4
identify==2.4.4
importlib-metadata==4.2.0
importlib-resources==5.2.3
iniconfig==1.1.1
mccabe==0.7.0
nodeenv==1.6.0
packaging==21.3
platformdirs==2.4.0
pluggy==1.0.0
pre-commit==2.17.0
py==1.11.0
pycodestyle==2.9.1
pyflakes==2.5.0
pyparsing==3.1.4
pytest==7.0.1
PyYAML==6.0.1
tokenize-rt==4.2.1
toml==0.10.2
tomli==1.2.3
typing_extensions==4.1.1
virtualenv==20.16.2
zipp==3.6.0

name: add-trailing-comma
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - cfgv==3.3.1
      - coverage==6.2
      - distlib==0.3.9
      - filelock==3.4.1
      - flake8==5.0.4
      - identify==2.4.4
      - importlib-metadata==4.2.0
      - importlib-resources==5.2.3
      - iniconfig==1.1.1
      - mccabe==0.7.0
      - nodeenv==1.6.0
      - packaging==21.3
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - pre-commit==2.17.0
      - py==1.11.0
      - pycodestyle==2.9.1
      - pyflakes==2.5.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pyyaml==6.0.1
      - tokenize-rt==4.2.1
      - toml==0.10.2
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - virtualenv==20.16.2
      - zipp==3.6.0
prefix: /opt/conda/envs/add-trailing-comma

tests/add_trailing_comma_test.py::test_fix_calls_noops[(\n
tests/add_trailing_comma_test.py::test_fix_calls_noops[x tests/add_trailing_comma_test.py::test_fix_calls_noops[x(1)] tests/add_trailing_comma_test.py::test_fix_calls_noops[tuple(\n tests/add_trailing_comma_test.py::test_fix_calls_noops[x(\n tests/add_trailing_comma_test.py::test_fix_calls_noops[x((\n tests/add_trailing_comma_test.py::test_ignores_invalid_ast_node tests/add_trailing_comma_test.py::test_py35_plus_rewrite tests/add_trailing_comma_test.py::test_auto_detected_py35_plus_rewrite[(1, tests/add_trailing_comma_test.py::test_auto_detected_py35_plus_rewrite[[1, tests/add_trailing_comma_test.py::test_auto_detected_py35_plus_rewrite[{1, tests/add_trailing_comma_test.py::test_auto_detected_py35_plus_rewrite[{1: tests/add_trailing_comma_test.py::test_auto_detected_py35_plus_rewrite[y(*args1, tests/add_trailing_comma_test.py::test_auto_detected_py35_plus_rewrite[y(**kwargs1, tests/add_trailing_comma_test.py::test_fixes_calls[x(\n tests/add_trailing_comma_test.py::test_fixes_calls[foo()(\n tests/add_trailing_comma_test.py::test_noop_one_line_literals[(1, tests/add_trailing_comma_test.py::test_noop_one_line_literals[[1, tests/add_trailing_comma_test.py::test_noop_one_line_literals[{1, tests/add_trailing_comma_test.py::test_noop_one_line_literals[{1: tests/add_trailing_comma_test.py::test_fixes_literals[x tests/add_trailing_comma_test.py::test_fixes_py35_plus_literals[x tests/add_trailing_comma_test.py::test_noop_tuple_literal_without_braces tests/add_trailing_comma_test.py::test_main_trivial tests/add_trailing_comma_test.py::test_main_noop tests/add_trailing_comma_test.py::test_main_changes_a_file tests/add_trailing_comma_test.py::test_main_syntax_error tests/add_trailing_comma_test.py::test_main_non_utf8_bytes tests/add_trailing_comma_test.py::test_main_py35_plus_argument_star_args tests/add_trailing_comma_test.py::test_main_py35_plus_argument_star_star_kwargs
add_trailing_comma.py
add_trailing_comma.py