diff --git a/hashin.py b/hashin.py
index 510e9bf..d2d1fe6 100755
--- a/hashin.py
+++ b/hashin.py
@@ -120,7 +120,6 @@ def run(spec, file, algorithm, python_versions=None, verbose=False):
 
 
 def amend_requirements_content(requirements, package, new_lines):
-
     # if the package wasn't already there, add it to the bottom
     if '%s==' % package not in requirements:
         # easy peasy
@@ -132,7 +131,7 @@ def amend_requirements_content(requirements, package, new_lines):
         lines = []
         padding = ' ' * 4
         for line in requirements.splitlines():
-            if '{0}=='.format(package) in line:
+            if line.startswith('{0}=='.format(package)):
                 lines.append(line)
             elif lines and line.startswith(padding):
                 lines.append(line)

Wrong package replaced when target name is found in existing package
For example, an attempt to add hashes for the `selenium` package replaces the `pytest-selenium` package. Another example would be `pytest-django` and `django`.

Before:
```ini
pytest-selenium==1.2.1 \
    --hash=sha256:e82f0a265b0e238ac42ac275d79313d0a7e0bef1a450633aeb3d6549cc14f517 \
    --hash=sha256:bd2121022ff3255ce82faec0ef3602462ec6bce9ca627b53462986cfc9b391e9
selenium==2.52.0 \
    --hash=sha256:820550a740ca1f746c399a0101986c0e6f94fbfe3c6f976e3f694db452cbe124
```

Command:
```bash
$ hashin selenium==2.53.1 requirements.txt
```

After:
```ini
selenium==2.53.1 \
    --hash=sha256:b1af142650ed7025f906349ae0d7ed1f1a1e635e6ce7ac67e2b2f854f9f8fdc1 \
    --hash=sha256:53929418a41295b526fbb68e43bc32fe93c3ef99c030b9e705caf1de486440de
```
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 839c27a..40c9d50 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -188,6 +188,29 @@ autocompeter==1.2.3  \\
         )
         self.assertEqual(result, previous + new_lines)
 
+    def test_amend_requirements_content_new_similar_name(self):
+        """This test came from https://github.com/peterbe/hashin/issues/15"""
+        previous_1 = """
+pytest-selenium==1.2.1 \
+    --hash=sha256:e82f0a265b0e238ac42ac275d79313d0a7e0bef1a450633aeb3d6549cc14f517 \
+    --hash=sha256:bd2121022ff3255ce82faec0ef3602462ec6bce9ca627b53462986cfc9b391e9
+        """.strip() + '\n'
+        previous_2 = """
+selenium==2.52.0 \
+    --hash=sha256:820550a740ca1f746c399a0101986c0e6f94fbfe3c6f976e3f694db452cbe124
+        """.strip() + '\n'
+        new_lines = """
+selenium==2.53.1 \
+    --hash=sha256:b1af142650ed7025f906349ae0d7ed1f1a1e635e6ce7ac67e2b2f854f9f8fdc1 \
+    --hash=sha256:53929418a41295b526fbb68e43bc32fe93c3ef99c030b9e705caf1de486440de
+        """.strip()
+        result = hashin.amend_requirements_content(
+            previous_1 + previous_2, 'selenium', new_lines
+        )
+        self.assertTrue(previous_1 in result)
+        self.assertTrue(previous_2 not in result)
+        self.assertTrue(new_lines in result)
+
     @cleanup_tmpdir('hashin*')
     @mock.patch('hashin.urlopen')
     def test_run(self, murlopen):

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest mock flake8 black therapist pytest-cov pytest-xdist pytest-mock pytest-asyncio pytest-bdd pytest-benchmark pytest-randomly responses hypothesis freezegun trustme requests-mock requests tomlkit
apt-get update apt-get install -y gcc
3.9
test-requirements.txt lint-requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==25.3.0
black==25.1.0
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
coverage==7.8.0
cryptography==44.0.2
exceptiongroup==1.2.2
execnet==2.1.1
flake8==7.2.0
freezegun==1.5.1
gherkin-official==29.0.0
-e git+https://github.com/peterbe/hashin.git@ce536a0cffac911124b9af4d14ec0ab79e32816a#egg=hashin
hypothesis==6.130.5
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
Mako==1.3.9
MarkupSafe==3.0.2
mccabe==0.7.0
mock==5.2.0
mypy-extensions==1.0.0
packaging==24.2
parse==1.20.2
parse_type==0.6.4
pathspec==0.12.1
platformdirs==4.3.7
pluggy==1.5.0
py-cpuinfo==9.0.0
pycodestyle==2.13.0
pycparser==2.22
pyflakes==3.3.1
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-bdd==8.1.0
pytest-benchmark==5.1.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-randomly==3.16.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
PyYAML==6.0.2
requests==2.32.3
requests-mock==1.12.1
responses==0.25.7
six==1.17.0
sortedcontainers==2.4.0
therapist==2.2.0
tomli==2.2.1
tomlkit==0.13.2
trustme==1.2.1
typing_extensions==4.13.0
urllib3==2.3.0
zipp==3.21.0

name: hashin
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:
      - attrs==25.3.0
      - black==25.1.0
      - certifi==2025.1.31
      - cffi==1.17.1
      - charset-normalizer==3.4.1
      - click==8.1.8
      - colorama==0.4.6
      - coverage==7.8.0
      - cryptography==44.0.2
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - flake8==7.2.0
      - freezegun==1.5.1
      - gherkin-official==29.0.0
      - hypothesis==6.130.5
      - idna==3.10
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - mako==1.3.9
      - markupsafe==3.0.2
      - mccabe==0.7.0
      - mock==5.2.0
      - mypy-extensions==1.0.0
      - packaging==24.2
      - parse==1.20.2
      - parse-type==0.6.4
      - pathspec==0.12.1
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - py-cpuinfo==9.0.0
      - pycodestyle==2.13.0
      - pycparser==2.22
      - pyflakes==3.3.1
      - pytest==8.3.5
      - pytest-asyncio==0.26.0
      - pytest-bdd==8.1.0
      - pytest-benchmark==5.1.0
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - pytest-randomly==3.16.0
      - pytest-xdist==3.6.1
      - python-dateutil==2.9.0.post0
      - pyyaml==6.0.2
      - requests==2.32.3
      - requests-mock==1.12.1
      - responses==0.25.7
      - six==1.17.0
      - sortedcontainers==2.4.0
      - therapist==2.2.0
      - tomli==2.2.1
      - tomlkit==0.13.2
      - trustme==1.2.1
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - zipp==3.21.0
prefix: /opt/conda/envs/hashin

tests/test_cli.py::Tests::test_amend_requirements_content_new_similar_name
tests/test_cli.py::Tests::test_run
tests/test_cli.py::Tests::test_amend_requirements_content_replacement_2 tests/test_cli.py::Tests::test_get_latest_version_simple tests/test_cli.py::Tests::test_amend_requirements_content_replacement_amonst_others_2 tests/test_cli.py::Tests::test_expand_python_version tests/test_cli.py::Tests::test_filter_releases tests/test_cli.py::Tests::test_get_hashes_error tests/test_cli.py::Tests::test_amend_requirements_content_replacement_amonst_others tests/test_cli.py::Tests::test_amend_requirements_content_new tests/test_cli.py::Tests::test_release_url_metadata_python tests/test_cli.py::Tests::test_amend_requirements_content_replacement tests/test_cli.py::Tests::test_amend_requirements_content_replacement_single_to_multi
hashin.py
hashin.py