diff --git a/pre_commit_hooks/requirements_txt_fixer.py b/pre_commit_hooks/requirements_txt_fixer.py
index 4575975..eff7935 100644
--- a/pre_commit_hooks/requirements_txt_fixer.py
+++ b/pre_commit_hooks/requirements_txt_fixer.py
@@ -40,11 +40,16 @@ class Requirement(object):
 
 def fix_requirements(f):  # type: (IO[bytes]) -> int
     requirements = []  # type: List[Requirement]
-    before = tuple(f)
+    before = list(f)
     after = []  # type: List[bytes]
 
     before_string = b''.join(before)
 
+    # adds new line in case one is missing
+    # AND a change to the requirements file is needed regardless:
+    if before and not before[-1].endswith(b'\n'):
+        before[-1] += b'\n'
+
     # If the file is empty (i.e. only whitespace/newlines) exit early
     if before_string.strip() == b'':
         return PASS

requirements-txt-fixer corrupts file if no new line at end
a file with
```
a
b
c
```
(no new line)
will get "fixed" to:
```
a
bc

```

I was able to debug and identify the issue, I'll be happy to also PR a fix but I was wondering if there is really a use for it? I've not seen any input without a new line at the end in the tests cases and as a work around I can add `end-of-file-fixer` before it.


diff --git a/tests/requirements_txt_fixer_test.py b/tests/requirements_txt_fixer_test.py
index c7c6e47..2e2eab6 100644
--- a/tests/requirements_txt_fixer_test.py
+++ b/tests/requirements_txt_fixer_test.py
@@ -15,6 +15,9 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement
         (b'foo\n# comment at end\n', PASS, b'foo\n# comment at end\n'),
         (b'foo\nbar\n', FAIL, b'bar\nfoo\n'),
         (b'bar\nfoo\n', PASS, b'bar\nfoo\n'),
+        (b'a\nc\nb\n', FAIL, b'a\nb\nc\n'),
+        (b'a\nc\nb', FAIL, b'a\nb\nc\n'),
+        (b'a\nb\nc', FAIL, b'a\nb\nc\n'),
         (
             b'#comment1\nfoo\n#comment2\nbar\n',
             FAIL,

pip install -e .
parse_log_pytest
requirements.txt
pytest
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
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
mock==5.2.0
nodeenv==1.6.0
packaging==21.3
platformdirs==2.4.0
pluggy==1.0.0
pre-commit==2.17.0
-e git+https://github.com/pre-commit/pre-commit-hooks.git@277f875bc517bbde5f767dcb0919e762c33759a9#egg=pre_commit_hooks
py==1.11.0
pycodestyle==2.9.1
pyflakes==2.5.0
pyparsing==3.1.4
pytest==7.0.1
PyYAML==6.0.1
ruamel.yaml==0.18.3
ruamel.yaml.clib==0.2.8
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
      - 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
      - mock==5.2.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
      - ruamel-yaml==0.18.3
      - ruamel-yaml-clib==0.2.8
      - 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/requirements_txt_fixer_test.py::test_integration[a\nc\nb-1-a\nb\nc\n] tests/requirements_txt_fixer_test.py::test_integration[a\nb\nc-1-a\nb\nc\n]
tests/requirements_txt_fixer_test.py::test_integration[-0-] tests/requirements_txt_fixer_test.py::test_integration[\n-0-\n] tests/requirements_txt_fixer_test.py::test_integration[# tests/requirements_txt_fixer_test.py::test_integration[foo\n# tests/requirements_txt_fixer_test.py::test_integration[foo\nbar\n-1-bar\nfoo\n] tests/requirements_txt_fixer_test.py::test_integration[bar\nfoo\n-0-bar\nfoo\n] tests/requirements_txt_fixer_test.py::test_integration[a\nc\nb\n-1-a\nb\nc\n] tests/requirements_txt_fixer_test.py::test_integration[#comment1\nfoo\n#comment2\nbar\n-1-#comment2\nbar\n#comment1\nfoo\n] tests/requirements_txt_fixer_test.py::test_integration[#comment1\nbar\n#comment2\nfoo\n-0-#comment1\nbar\n#comment2\nfoo\n] tests/requirements_txt_fixer_test.py::test_integration[#comment\n\nfoo\nbar\n-1-#comment\n\nbar\nfoo\n] tests/requirements_txt_fixer_test.py::test_integration[#comment\n\nbar\nfoo\n-0-#comment\n\nbar\nfoo\n] tests/requirements_txt_fixer_test.py::test_integration[\nfoo\nbar\n-1-bar\n\nfoo\n] tests/requirements_txt_fixer_test.py::test_integration[\nbar\nfoo\n-0-\nbar\nfoo\n] tests/requirements_txt_fixer_test.py::test_integration[pyramid==1\npyramid-foo==2\n-0-pyramid==1\npyramid-foo==2\n] tests/requirements_txt_fixer_test.py::test_integration[ocflib\nDjango\nPyMySQL\n-1-Django\nocflib\nPyMySQL\n] tests/requirements_txt_fixer_test.py::test_integration[-e tests/requirements_txt_fixer_test.py::test_integration[bar\npkg-resources==0.0.0\nfoo\n-1-bar\nfoo\n] tests/requirements_txt_fixer_test.py::test_integration[foo\npkg-resources==0.0.0\nbar\n-1-bar\nfoo\n] tests/requirements_txt_fixer_test.py::test_requirement_object
pre_commit_hooks/requirements_txt_fixer.py
pre_commit_hooks/requirements_txt_fixer.py