diff --git a/pre_commit_hooks/mixed_line_ending.py b/pre_commit_hooks/mixed_line_ending.py
index 301c654..a163726 100644
--- a/pre_commit_hooks/mixed_line_ending.py
+++ b/pre_commit_hooks/mixed_line_ending.py
@@ -55,7 +55,8 @@ def fix_filename(filename, fix):
     else:
         target_ending = FIX_TO_LINE_ENDING[fix]
         # find if there are lines with *other* endings
-        del counts[target_ending]
+        # It's possible there's no line endings of the target type
+        counts.pop(target_ending, None)
         other_endings = bool(sum(counts.values()))
         if other_endings:
             _fix(filename, contents, target_ending)

mixed-line-ending -- KeyError: b'\n'
`pre-commit 1.1.2`

```bash
Mixed line ending........................................................Failed
hookid: mixed-line-ending

Traceback (most recent call last):
  File "/home/gary/.cache/pre-commit/repos71slzol/py_env-python3.6/bin/mixed-line-ending", line 11, in <module>
    load_entry_point('pre-commit-hooks==0.9.4', 'console_scripts', 'mixed-line-ending')()
  File "/home/gary/.cache/pre-commit/repos71slzol/py_env-python3.6/lib/python3.6/site-packages/pre_commit_hooks/mixed_line_ending.py", line 78, in main
    retv |= fix_filename(filename, args.fix)
  File "/home/gary/.cache/pre-commit/repos71slzol/py_env-python3.6/lib/python3.6/site-packages/pre_commit_hooks/mixed_line_ending.py", line 58, in fix_filename
    del counts[target_ending]
KeyError: b'\n'
```
```yaml
-   repo: git://github.com/pre-commit/pre-commit-hooks
    sha: v0.9.4
    hooks:
    -   id: mixed-line-ending
        args: [--fix=lf]
```


diff --git a/tests/mixed_line_ending_test.py b/tests/mixed_line_ending_test.py
index 808295b..23837cd 100644
--- a/tests/mixed_line_ending_test.py
+++ b/tests/mixed_line_ending_test.py
@@ -101,3 +101,13 @@ def test_fix_crlf(tmpdir):
 
     assert ret == 1
     assert path.read_binary() == b'foo\r\nbar\r\nbaz\r\n'
+
+
+def test_fix_lf_all_crlf(tmpdir):
+    """Regression test for #239"""
+    path = tmpdir.join('input.txt')
+    path.write_binary(b'foo\r\nbar\r\n')
+    ret = main(('--fix=lf', path.strpath))
+
+    assert ret == 1
+    assert path.read_binary() == b'foo\nbar\n'

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
apt-get update apt-get install -y gcc
3.6
requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
autopep8==2.0.4
certifi==2021.5.30
cfgv==3.3.1
coverage==6.2
distlib==0.3.9
execnet==1.9.0
filelock==3.4.1
flake8==2.5.5
identify==2.4.4
importlib-metadata==4.2.0
importlib-resources==5.2.3
iniconfig==1.1.1
mccabe==0.4.0
mock==5.2.0
nodeenv==1.6.0
packaging==21.3
pep8==1.7.1
platformdirs==2.4.0
pluggy==1.0.0
pre-commit==2.17.0
-e git+https://github.com/pre-commit/pre-commit-hooks.git@efdceb4e40cda10780f4646ec944f55b5786190d#egg=pre_commit_hooks
py==1.11.0
pycodestyle==2.10.0
pyflakes==1.0.0
pyparsing==3.1.4
pytest==7.0.1
pytest-asyncio==0.16.0
pytest-cov==4.0.0
pytest-mock==3.6.1
pytest-xdist==3.0.2
PyYAML==6.0.1
simplejson==3.20.1
six==1.17.0
toml==0.10.2
tomli==1.2.3
typing_extensions==4.1.1
virtualenv==20.16.2
zipp==3.6.0

name: pre-commit-hooks
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
      - autopep8==2.0.4
      - cfgv==3.3.1
      - coverage==6.2
      - distlib==0.3.9
      - execnet==1.9.0
      - filelock==3.4.1
      - flake8==2.5.5
      - identify==2.4.4
      - importlib-metadata==4.2.0
      - importlib-resources==5.2.3
      - iniconfig==1.1.1
      - mccabe==0.4.0
      - mock==5.2.0
      - nodeenv==1.6.0
      - packaging==21.3
      - pep8==1.7.1
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - pre-commit==2.17.0
      - py==1.11.0
      - pycodestyle==2.10.0
      - pyflakes==1.0.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-asyncio==0.16.0
      - pytest-cov==4.0.0
      - pytest-mock==3.6.1
      - pytest-xdist==3.0.2
      - pyyaml==6.0.1
      - simplejson==3.20.1
      - six==1.17.0
      - 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/pre-commit-hooks

tests/mixed_line_ending_test.py::test_fix_lf_all_crlf
tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\r\nbar\nbaz\n-foo\nbar\nbaz\n] tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\r\nbar\nbaz\r\n-foo\r\nbar\r\nbaz\r\n] tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\rbar\nbaz\r-foo\rbar\rbaz\r] tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\r\nbar\n-foo\nbar\n] tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\rbar\n-foo\nbar\n] tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\r\nbar\r-foo\r\nbar\r\n] tests/mixed_line_ending_test.py::test_mixed_line_ending_fixes_auto[foo\r\nbar\nbaz\r-foo\nbar\nbaz\n] tests/mixed_line_ending_test.py::test_non_mixed_no_newline_end_of_file tests/mixed_line_ending_test.py::test_mixed_no_newline_end_of_file tests/mixed_line_ending_test.py::test_line_endings_ok[--fix=auto-foo\r\nbar\r\nbaz\r\n] tests/mixed_line_ending_test.py::test_line_endings_ok[--fix=auto-foo\rbar\rbaz\r] tests/mixed_line_ending_test.py::test_line_endings_ok[--fix=auto-foo\nbar\nbaz\n] tests/mixed_line_ending_test.py::test_line_endings_ok[--fix=crlf-foo\r\nbar\r\nbaz\r\n] tests/mixed_line_ending_test.py::test_line_endings_ok[--fix=lf-foo\nbar\nbaz\n] tests/mixed_line_ending_test.py::test_no_fix_does_not_modify tests/mixed_line_ending_test.py::test_fix_lf tests/mixed_line_ending_test.py::test_fix_crlf
pre_commit_hooks/mixed_line_ending.py
pre_commit_hooks/mixed_line_ending.py