diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index f261e54..a3bb7a4 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,5 +1,5 @@
 -   repo: https://github.com/pre-commit/pre-commit-hooks
-    sha: 9ba5af45ce2d29b64c9a348a6fcff5553eea1f2c
+    sha: v0.7.0
     hooks:
     -   id: trailing-whitespace
     -   id: end-of-file-fixer
@@ -13,12 +13,12 @@
     -   id: requirements-txt-fixer
     -   id: flake8
 -   repo: https://github.com/pre-commit/pre-commit
-    sha: 8dba3281d5051060755459dcf88e28fc26c27526
+    sha: v0.12.2
     hooks:
     -   id: validate_config
     -   id: validate_manifest
 -   repo: https://github.com/asottile/reorder_python_imports
-    sha: 3d86483455ab5bd06cc1069fdd5ac57be5463f10
+    sha: v0.3.1
     hooks:
     -   id: reorder-python-imports
         language_version: python2.7
diff --git a/pre_commit_hooks/trailing_whitespace_fixer.py b/pre_commit_hooks/trailing_whitespace_fixer.py
index fa9b7dd..d23d58d 100644
--- a/pre_commit_hooks/trailing_whitespace_fixer.py
+++ b/pre_commit_hooks/trailing_whitespace_fixer.py
@@ -10,10 +10,14 @@ from pre_commit_hooks.util import cmd_output
 def _fix_file(filename, is_markdown):
     with open(filename, mode='rb') as file_processed:
         lines = file_processed.readlines()
-    lines = [_process_line(line, is_markdown) for line in lines]
-    with open(filename, mode='wb') as file_processed:
-        for line in lines:
-            file_processed.write(line)
+    newlines = [_process_line(line, is_markdown) for line in lines]
+    if newlines != lines:
+        with open(filename, mode='wb') as file_processed:
+            for line in newlines:
+                file_processed.write(line)
+        return True
+    else:
+        return False
 
 
 def _process_line(line, is_markdown):
@@ -55,8 +59,9 @@ def fix_trailing_whitespace(argv=None):
         parser.error('--markdown-linebreak-ext requires a non-empty argument')
     all_markdown = '*' in md_args
     # normalize all extensions; split at ',', lowercase, and force 1 leading '.'
-    md_exts = ['.' + x.lower().lstrip('.')
-               for x in ','.join(md_args).split(',')]
+    md_exts = [
+        '.' + x.lower().lstrip('.') for x in ','.join(md_args).split(',')
+    ]
 
     # reject probable "eaten" filename as extension (skip leading '.' with [1:])
     for ext in md_exts:
@@ -69,10 +74,11 @@ def fix_trailing_whitespace(argv=None):
 
     return_code = 0
     for bad_whitespace_file in bad_whitespace_files:
-        print('Fixing {0}'.format(bad_whitespace_file))
         _, extension = os.path.splitext(bad_whitespace_file.lower())
-        _fix_file(bad_whitespace_file, all_markdown or extension in md_exts)
-        return_code = 1
+        md = all_markdown or extension in md_exts
+        if _fix_file(bad_whitespace_file, md):
+            print('Fixing {}'.format(bad_whitespace_file))
+            return_code = 1
     return return_code
 
 

DOS ending files fail, claim they are rewritten, but don't change file contents (trailing-whitespace-fixer)
diff --git a/tests/trailing_whitespace_fixer_test.py b/tests/trailing_whitespace_fixer_test.py
index 3a72ccb..eb2a1d0 100644
--- a/tests/trailing_whitespace_fixer_test.py
+++ b/tests/trailing_whitespace_fixer_test.py
@@ -20,6 +20,22 @@ def test_fixes_trailing_whitespace(input_s, expected, tmpdir):
     assert path.read() == expected
 
 
+def test_ok_with_dos_line_endings(tmpdir):
+    filename = tmpdir.join('f')
+    filename.write_binary(b'foo\r\nbar\r\nbaz\r\n')
+    ret = fix_trailing_whitespace((filename.strpath,))
+    assert filename.read_binary() == b'foo\r\nbar\r\nbaz\r\n'
+    assert ret == 0
+
+
+def test_markdown_ok(tmpdir):
+    filename = tmpdir.join('foo.md')
+    filename.write_binary(b'foo  \n')
+    ret = fix_trailing_whitespace((filename.strpath,))
+    assert filename.read_binary() == b'foo  \n'
+    assert ret == 0
+
+
 # filename, expected input, expected output
 MD_TESTS_1 = (
     ('foo.md', 'foo  \nbar \n  ', 'foo  \nbar\n\n'),

pip install -e .
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
attrs==22.2.0
autopep8==2.0.4
certifi==2021.5.30
cfgv==3.3.1
coverage==6.2
distlib==0.3.9
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@46251c9523506b68419aefdf5ff6ff2fbc4506a4#egg=pre_commit_hooks
py==1.11.0
pycodestyle==2.10.0
pyflakes==1.0.0
pyparsing==3.1.4
pytest==7.0.1
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
      - 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
      - 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/trailing_whitespace_fixer_test.py::test_ok_with_dos_line_endings tests/trailing_whitespace_fixer_test.py::test_markdown_ok
tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_whitespace[foo tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_whitespace[bar\t\nbaz\t\n-bar\nbaz\n] tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[foo.md-foo tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[bar.Markdown-bar tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[.md-baz tests/trailing_whitespace_fixer_test.py::test_fixes_trailing_markdown_whitespace[txt-foo tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[foo.txt-foo tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[bar.Markdown-bar tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[bar.MD-bar tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[.txt-baz tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt[txt-foo tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt_all[foo.baz-foo tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_opt_all[bar-bar tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_badopt[--] tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_badopt[a.b] tests/trailing_whitespace_fixer_test.py::test_markdown_linebreak_ext_badopt[a/b] tests/trailing_whitespace_fixer_test.py::test_no_markdown_linebreak_ext_opt[bar.md-bar tests/trailing_whitespace_fixer_test.py::test_no_markdown_linebreak_ext_opt[bar.markdown-baz tests/trailing_whitespace_fixer_test.py::test_returns_zero_for_no_changes tests/trailing_whitespace_fixer_test.py::test_preserve_non_utf8_file
pre_commit_hooks/trailing_whitespace_fixer.py .pre-commit-config.yaml
pre_commit_hooks/trailing_whitespace_fixer.py .pre-commit-config.yaml