diff --git a/pre_commit_hooks/string_fixer.py b/pre_commit_hooks/string_fixer.py
index a5ea1ea..a41b737 100644
--- a/pre_commit_hooks/string_fixer.py
+++ b/pre_commit_hooks/string_fixer.py
@@ -31,13 +31,13 @@ def handle_match(token_text):  # type: (str) -> str
 def get_line_offsets_by_line_no(src):  # type: (str) -> List[int]
     # Padded so we can index with line number
     offsets = [-1, 0]
-    for line in src.splitlines():
-        offsets.append(offsets[-1] + len(line) + 1)
+    for line in src.splitlines(True):
+        offsets.append(offsets[-1] + len(line))
     return offsets
 
 
 def fix_strings(filename):  # type: (str) -> int
-    with io.open(filename, encoding='UTF-8') as f:
+    with io.open(filename, encoding='UTF-8', newline='') as f:
         contents = f.read()
     line_offsets = get_line_offsets_by_line_no(contents)
 
@@ -58,8 +58,8 @@ def fix_strings(filename):  # type: (str) -> int
 
     new_contents = ''.join(splitcontents)
     if contents != new_contents:
-        with io.open(filename, 'w', encoding='UTF-8') as write_handle:
-            write_handle.write(new_contents)
+        with io.open(filename, 'w', encoding='UTF-8', newline='') as f:
+            f.write(new_contents)
         return 1
     else:
         return 0

double-quote-string-fixer change linebreak on windows
I'm using `mixed-line-ending` and  `double-quote-string-fixer` on windows'
If `double-quote-string-fixer` changes file content, origin `LF` ending will be convert to `CRLF` ending.
diff --git a/tests/string_fixer_test.py b/tests/string_fixer_test.py
index a65213b..4adca4a 100644
--- a/tests/string_fixer_test.py
+++ b/tests/string_fixer_test.py
@@ -44,8 +44,15 @@ TESTS = (
 
 @pytest.mark.parametrize(('input_s', 'output', 'expected_retval'), TESTS)
 def test_rewrite(input_s, output, expected_retval, tmpdir):
-    path = tmpdir.join('file.txt')
+    path = tmpdir.join('file.py')
     path.write(input_s)
     retval = main([path.strpath])
     assert path.read() == output
     assert retval == expected_retval
+
+
+def test_rewrite_crlf(tmpdir):
+    f = tmpdir.join('f.py')
+    f.write_binary(b'"foo"\r\n"bar"\r\n')
+    assert main((f.strpath,))
+    assert f.read_binary() == b"'foo'\r\n'bar'\r\n"

pip install -e .
parse_log_pytest
requirements.txt
3.9
requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
cfgv==3.4.0
coverage==7.8.0
distlib==0.3.9
exceptiongroup==1.2.2
filelock==3.18.0
flake8==7.2.0
identify==2.6.9
iniconfig==2.1.0
mccabe==0.7.0
mock==5.2.0
nodeenv==1.9.1
packaging==24.2
platformdirs==4.3.7
pluggy==1.5.0
pre_commit==4.2.0
-e git+https://github.com/pre-commit/pre-commit-hooks.git@e8e54f7f99d61a6f60373b87ac4932d70bda58d9#egg=pre_commit_hooks
pycodestyle==2.13.0
pyflakes==3.3.1
pytest==8.3.5
PyYAML==6.0.2
ruamel.yaml==0.18.10
ruamel.yaml.clib==0.2.12
six==1.17.0
tomli==2.2.1
virtualenv==20.29.3

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
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - 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=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - cfgv==3.4.0
      - coverage==7.8.0
      - distlib==0.3.9
      - exceptiongroup==1.2.2
      - filelock==3.18.0
      - flake8==7.2.0
      - identify==2.6.9
      - iniconfig==2.1.0
      - mccabe==0.7.0
      - mock==5.2.0
      - nodeenv==1.9.1
      - packaging==24.2
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - pre-commit==4.2.0
      - pycodestyle==2.13.0
      - pyflakes==3.3.1
      - pytest==8.3.5
      - pyyaml==6.0.2
      - ruamel-yaml==0.18.10
      - ruamel-yaml-clib==0.2.12
      - six==1.17.0
      - tomli==2.2.1
      - virtualenv==20.29.3
prefix: /opt/conda/envs/pre-commit-hooks

tests/string_fixer_test.py::test_rewrite_crlf
tests/string_fixer_test.py::test_rewrite[''-''-0] tests/string_fixer_test.py::test_rewrite[""-''-1] tests/string_fixer_test.py::test_rewrite["\\'"-"\\'"-0_0] tests/string_fixer_test.py::test_rewrite["\\""-"\\""-0] tests/string_fixer_test.py::test_rewrite['\\"\\"'-'\\"\\"'-0] tests/string_fixer_test.py::test_rewrite[x tests/string_fixer_test.py::test_rewrite["\\'"-"\\'"-0_1] tests/string_fixer_test.py::test_rewrite[""" tests/string_fixer_test.py::test_rewrite[\nx tests/string_fixer_test.py::test_rewrite["foo""bar"-'foo''bar'-1]
pre_commit_hooks/string_fixer.py
pre_commit_hooks/string_fixer.py