diff --git a/lasio/writer.py b/lasio/writer.py
index 1f3bf3f..b007a92 100644
--- a/lasio/writer.py
+++ b/lasio/writer.py
@@ -3,6 +3,8 @@ import textwrap
 
 import numpy as np
 
+from copy import deepcopy
+
 from .las_items import HeaderItem, CurveItem, SectionItems, OrderedDict
 from . import defaults
 from . import exceptions
@@ -57,6 +59,11 @@ def write(
     reflect the ~Data section's units and the actual first, last, and interval
     values.
 
+    However, passing a version to this write() function only changes the version
+    of the object written to. Example: las.write(myfile, version=2).
+    Lasio's internal-las-object version will remain separate and defined by
+    las.version.VERS.value
+
     You should avoid calling this function directly - instead use the
     :meth:`lasio.LASFile.write` method.
 
@@ -73,15 +80,17 @@ def write(
         las.version["WRAP"] = HeaderItem("WRAP", "", "NO", "One line per depth step")
     lines = []
 
+    version_section_to_write = deepcopy(las.version)
+    
     assert version in (1.2, 2, None)
     if version is None:
         version = las.version["VERS"].value
     if version == 1.2:
-        las.version["VERS"] = HeaderItem(
+        version_section_to_write.VERS = HeaderItem(
             "VERS", "", 1.2, "CWLS LOG ASCII STANDARD - VERSION 1.2"
         )
     elif version == 2:
-        las.version["VERS"] = HeaderItem(
+        version_section_to_write.VERS = HeaderItem(
             "VERS", "", 2.0, "CWLS log ASCII Standard -VERSION 2.0"
         )
 
@@ -113,11 +122,11 @@ def write(
     # get_formatter_function ( ** get_section_widths )
 
     # ~Version
-    logger.debug("LASFile.write Version section")
+    logger.debug("LASFile.write Version section, Version: %s" % (version))
     lines.append("~Version ".ljust(header_width, "-"))
     order_func = get_section_order_function("Version", version)
-    section_widths = get_section_widths("Version", las.version, version, order_func)
-    for header_item in las.version.values():
+    section_widths = get_section_widths("Version", version_section_to_write, version, order_func)
+    for header_item in version_section_to_write.values():
         mnemonic = header_item.original_mnemonic
         # logger.debug('LASFile.write ' + str(header_item))
         order = order_func(mnemonic)
@@ -226,7 +235,7 @@ def write(
             lines = [depth_slice]
 
         for line in lines:
-            if las.version["VERS"].value == 1.2 and len(line) > 255:
+            if version_section_to_write.VERS == 1.2 and len(line) > 255:
                 logger.warning(
                     "[v1.2] line #{} has {} chars (>256)".format(
                         line_counter + 1, len(line)

write(version=X) is overwriting las.version.VERS
If you call ``las.write('blah.las', version=2)`` when ``las.version.VERS.value`` is 1.2, then after the file is written, ``las.version.VERS.value`` becomes 2.0. This is incorrect behaviour. Changing the version in the write method should only affect the file being written.

The code is simple enough to change, but then it appears the wrong behaviour is happening. Needs proper  investigation and a unit test.
diff --git a/tests/test_write.py b/tests/test_write.py
index bccfc5b..aa5384e 100644
--- a/tests/test_write.py
+++ b/tests/test_write.py
@@ -491,3 +491,150 @@ between 625 metres and 615 metres to be invalid.
 ~ASCII -----------------------------------------------------
  1670.00000  123.45000 2550.00000    0.45000  123.45000  123.45000  110.20000  105.60000
 '''
+
+
+def test_write_12_to_20_ver_in_mem_is_12():
+    las = read(egfn("1.2/sample.las"))
+    s = StringIO()
+    las.write(s, version=2)
+    s.seek(0)
+    assert las.version.VERS.value == 1.2
+    assert s.read() == '''~Version ---------------------------------------------------
+VERS. 2.0 : CWLS log ASCII Standard -VERSION 2.0
+WRAP.  NO : ONE LINE PER DEPTH STEP
+~Well ------------------------------------------------------
+STRT.M                  1670.0 : 
+STOP.M                 1669.75 : 
+STEP.M                  -0.125 : 
+NULL.                  -999.25 : 
+COMP.   # ANY OIL COMPANY LTD. : COMPANY
+WELL.   ANY ET AL OIL WELL #12 : WELL
+FLD .                     EDAM : FIELD
+LOC .           A9-16-49-20W3M : LOCATION
+PROV.             SASKATCHEWAN : PROVINCE
+SRVC. ANY LOGGING COMPANY LTD. : SERVICE COMPANY
+DATE.              25-DEC-1988 : LOG DATE
+UWI .         100091604920W300 : UNIQUE WELL ID
+~Curve Information -----------------------------------------
+DEPT.M     : 1  DEPTH
+DT  .US/M  : 2  SONIC TRANSIT TIME
+RHOB.K/M3  : 3  BULK DENSITY
+NPHI.V/V   : 4   NEUTRON POROSITY
+SFLU.OHMM  : 5  RXO RESISTIVITY
+SFLA.OHMM  : 6  SHALLOW RESISTIVITY
+ILM .OHMM  : 7  MEDIUM RESISTIVITY
+ILD .OHMM  : 8  DEEP RESISTIVITY
+~Params ----------------------------------------------------
+BHT .DEGC   35.5 : BOTTOM HOLE TEMPERATURE
+BS  .MM    200.0 : BIT SIZE
+FD  .K/M3 1000.0 : FLUID DENSITY
+MATR.        0.0 : NEUTRON MATRIX(0=LIME,1=SAND,2=DOLO)
+MDEN.     2710.0 : LOGGING MATRIX DENSITY
+RMF .OHMM  0.216 : MUD FILTRATE RESISTIVITY
+DFD .K/M3 1525.0 : DRILL FLUID DENSITY
+~Other -----------------------------------------------------
+Note: The logging tools became stuck at 625 meters causing the data
+between 625 meters and 615 meters to be invalid.
+~ASCII -----------------------------------------------------
+ 1670.00000  123.45000 2550.00000    0.45000  123.45000  123.45000  110.20000  105.60000
+ 1669.87500  123.45000 2550.00000    0.45000  123.45000  123.45000  110.20000  105.60000
+ 1669.75000  123.45000 2550.00000    0.45000  123.45000  123.45000  110.20000  105.60000
+'''
+
+def test_write_12_to_20_ver():
+    las = read(egfn("1.2/sample.las"))
+    las.version.VERS.value = 2
+    s = StringIO()
+    las.write(s)
+    s.seek(0)
+    assert las.version.VERS.value != 1.2
+    assert s.read() == '''~Version ---------------------------------------------------
+VERS. 2.0 : CWLS log ASCII Standard -VERSION 2.0
+WRAP.  NO : ONE LINE PER DEPTH STEP
+~Well ------------------------------------------------------
+STRT.M                  1670.0 : 
+STOP.M                 1669.75 : 
+STEP.M                  -0.125 : 
+NULL.                  -999.25 : 
+COMP.   # ANY OIL COMPANY LTD. : COMPANY
+WELL.   ANY ET AL OIL WELL #12 : WELL
+FLD .                     EDAM : FIELD
+LOC .           A9-16-49-20W3M : LOCATION
+PROV.             SASKATCHEWAN : PROVINCE
+SRVC. ANY LOGGING COMPANY LTD. : SERVICE COMPANY
+DATE.              25-DEC-1988 : LOG DATE
+UWI .         100091604920W300 : UNIQUE WELL ID
+~Curve Information -----------------------------------------
+DEPT.M     : 1  DEPTH
+DT  .US/M  : 2  SONIC TRANSIT TIME
+RHOB.K/M3  : 3  BULK DENSITY
+NPHI.V/V   : 4   NEUTRON POROSITY
+SFLU.OHMM  : 5  RXO RESISTIVITY
+SFLA.OHMM  : 6  SHALLOW RESISTIVITY
+ILM .OHMM  : 7  MEDIUM RESISTIVITY
+ILD .OHMM  : 8  DEEP RESISTIVITY
+~Params ----------------------------------------------------
+BHT .DEGC   35.5 : BOTTOM HOLE TEMPERATURE
+BS  .MM    200.0 : BIT SIZE
+FD  .K/M3 1000.0 : FLUID DENSITY
+MATR.        0.0 : NEUTRON MATRIX(0=LIME,1=SAND,2=DOLO)
+MDEN.     2710.0 : LOGGING MATRIX DENSITY
+RMF .OHMM  0.216 : MUD FILTRATE RESISTIVITY
+DFD .K/M3 1525.0 : DRILL FLUID DENSITY
+~Other -----------------------------------------------------
+Note: The logging tools became stuck at 625 meters causing the data
+between 625 meters and 615 meters to be invalid.
+~ASCII -----------------------------------------------------
+ 1670.00000  123.45000 2550.00000    0.45000  123.45000  123.45000  110.20000  105.60000
+ 1669.87500  123.45000 2550.00000    0.45000  123.45000  123.45000  110.20000  105.60000
+ 1669.75000  123.45000 2550.00000    0.45000  123.45000  123.45000  110.20000  105.60000
+'''
+
+
+def test_write_20_to_12_ver_in_mem_is_20():
+    las = read(egfn("2.0/sample_2.0.las"))
+    s = StringIO()
+    las.write(s, version=1.2)
+    s.seek(0)
+    assert s.read() == '''~Version ---------------------------------------------------
+VERS. 1.2 : CWLS LOG ASCII STANDARD - VERSION 1.2
+WRAP.  NO : ONE LINE PER DEPTH STEP
+~Well ------------------------------------------------------
+STRT.M         1670.0 : START DEPTH
+STOP.M        1669.75 : STOP DEPTH
+STEP.M         -0.125 : STEP
+NULL.         -999.25 : NULL VALUE
+COMP.         COMPANY : ANY OIL COMPANY INC.
+WELL.            WELL : AAAAA_2
+FLD .           FIELD : WILDCAT
+LOC .        LOCATION : 12-34-12-34W5M
+PROV.        PROVINCE : ALBERTA
+SRVC. SERVICE COMPANY : ANY LOGGING COMPANY INC.
+DATE.        LOG DATE : 13-DEC-86
+UWI .  UNIQUE WELL ID : 100123401234W500
+~Curve Information -----------------------------------------
+DEPT.M                 : 1  DEPTH
+DT  .US/M 60 520 32 00 : 2  SONIC TRANSIT TIME
+RHOB.K/M3 45 350 01 00 : 3  BULK DENSITY
+NPHI.V/V  42 890 00 00 : 4  NEUTRON POROSITY
+SFLU.OHMM 07 220 04 00 : 5  SHALLOW RESISTIVITY
+SFLA.OHMM 07 222 01 00 : 6  SHALLOW RESISTIVITY
+ILM .OHMM 07 120 44 00 : 7  MEDIUM RESISTIVITY
+ILD .OHMM 07 120 46 00 : 8  DEEP RESISTIVITY
+~Params ----------------------------------------------------
+MUD .   GEL CHEM : MUD TYPE
+BHT .DEGC   35.5 : BOTTOM HOLE TEMPERATURE
+BS  .MM    200.0 : BIT SIZE
+FD  .K/M3 1000.0 : FLUID DENSITY
+MATR.       SAND : NEUTRON MATRIX
+MDEN.     2710.0 : LOGGING MATRIX DENSITY
+RMF .OHMM  0.216 : MUD FILTRATE RESISTIVITY
+DFD .K/M3 1525.0 : DRILL FLUID DENSITY
+~Other -----------------------------------------------------
+Note: The logging tools became stuck at 625 metres causing the data
+between 625 metres and 615 metres to be invalid.
+~ASCII -----------------------------------------------------
+ 1670.00000  123.45000 2550.00000    0.45000  123.45000  123.45000  110.20000  105.60000
+ 1669.87500  123.45000 2550.00000    0.45000  123.45000  123.45000  110.20000  105.60000
+ 1669.75000  123.45000 2550.00000    0.45000  123.45000  123.45000  110.20000  105.60000
+'''

pip install -e .[all]
parse_log_pytest
requirements.txt
pytest>=3.6 pytest-cov coverage codecov
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
cchardet==2.1.7
certifi==2021.5.30
charset-normalizer==2.0.12
codecov==2.1.13
coverage==6.2
et-xmlfile==1.1.0
idna==3.10
importlib-metadata==4.8.3
iniconfig==1.1.1
-e git+https://github.com/kinverarity1/lasio.git@f9fc3d0e934f3be5f26d23e894cccb6cb2e3ea0a#egg=lasio
numpy==1.19.5
openpyxl==3.1.3
packaging==21.3
pandas==1.1.5
pluggy==1.0.0
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
pytest-cov==4.0.0
python-dateutil==2.9.0.post0
pytz==2025.2
requests==2.27.1
six==1.17.0
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
zipp==3.6.0

name: lasio
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:
      - argparse==1.4.0
      - attrs==22.2.0
      - cchardet==2.1.7
      - charset-normalizer==2.0.12
      - codecov==2.1.13
      - coverage==6.2
      - et-xmlfile==1.1.0
      - idna==3.10
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - numpy==1.19.5
      - openpyxl==3.1.3
      - packaging==21.3
      - pandas==1.1.5
      - pluggy==1.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - requests==2.27.1
      - six==1.17.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - zipp==3.6.0
prefix: /opt/conda/envs/lasio

tests/test_write.py::test_write_12_to_20_ver_in_mem_is_12
tests/test_write.py::test_write_sect_widths_12 tests/test_write.py::test_write_to_filename tests/test_write.py::test_write_sect_widths_12_curves tests/test_write.py::test_write_sect_widths_20_narrow tests/test_write.py::test_write_sect_widths_20_wide tests/test_write.py::test_write_sample_empty_params tests/test_write.py::test_df_curve_addition_on_export tests/test_write.py::test_write_xlsx tests/test_write.py::test_export_xlsx tests/test_write.py::test_multi_curve_mnemonics_rewrite tests/test_write.py::test_multi_curve_missing_mnemonics_rewrite tests/test_write.py::test_write_units tests/test_write.py::test_to_csv_units_None tests/test_write.py::test_to_csv_units_line tests/test_write.py::test_to_csv_units_parentheses tests/test_write.py::test_to_csv_units_brackets tests/test_write.py::test_to_csv_specify_mnemonics tests/test_write.py::test_to_csv_specify_units tests/test_write.py::test_rename_and_write_curve_mnemonic tests/test_write.py::test_write_large_depths tests/test_write.py::test_write_single_step tests/test_write.py::test_write_12_to_20_ver tests/test_write.py::test_write_20_to_12_ver_in_mem_is_20
lasio/writer.py
lasio/writer.py