diff --git a/nccompress/ncfind.py b/nccompress/ncfind.py
index b329dc2..8234b53 100755
--- a/nccompress/ncfind.py
+++ b/nccompress/ncfind.py
@@ -25,7 +25,7 @@ def is_netCDF_compressed(ncfile):
         isnetCDF=True
         iscompressed = is_compressed(fh)
         fh.close
-    except RuntimeError:
+    except:
         # Don't do anything
         pass
     return isnetCDF, iscompressed
@@ -71,13 +71,15 @@ def parse_args(arglist):
 
     return parser.parse_args(arglist)
     
-def main(args):
+def find_files(args):
     
     # verbose=args.verbose
 
     findcompressed = args.compressed
     finduncompressed = args.uncompressed
 
+    found_files = []
+
     # If neither are specified make them both true, find any kind of netCDF file
     if not finduncompressed and not findcompressed:
         findcompressed = True
@@ -131,11 +133,20 @@ def main(args):
                 if isnetCDF:
                     if iscompressed:
                         ncompressed += 1
-                        if findcompressed: sys.stdout.write(filepath+"\n")
+                        if findcompressed: found_files.append(filepath)
                     else:
                         nuncompressed += 1
-                        if finduncompressed: sys.stdout.write(filepath+"\n")
+                        if finduncompressed: found_files.append(filepath)
+
+    return found_files
+
+def main(args):
+
+    found_files = find_files(args)
 
+    if found_files:
+        for file in found_files:
+            sys.stdout.write(file+"\n")
                 
 def main_parse_args(arglist):
     """

Error catching didn't work
> Traceback (most recent call last):
  File "/g/data3/hh5/public/apps/miniconda3/envs/analysis3-18.04/bin/ncfind", line 10, in <module>
    sys.exit(main_argv())
  File "/g/data3/hh5/public/apps/miniconda3/envs/analysis3-18.04/lib/python3.6/site-packages/nccompress/ncfind.py", line 152, in main_argv
    main_parse_args(sys.argv[1:])
  File "/g/data3/hh5/public/apps/miniconda3/envs/analysis3-18.04/lib/python3.6/site-packages/nccompress/ncfind.py", line 146, in main_parse_args
    return main(parse_args(arglist))
  File "/g/data3/hh5/public/apps/miniconda3/envs/analysis3-18.04/lib/python3.6/site-packages/nccompress/ncfind.py", line 130, in main
    isnetCDF, iscompressed =  is_netCDF_compressed(filepath)
  File "/g/data3/hh5/public/apps/miniconda3/envs/analysis3-18.04/lib/python3.6/site-packages/nccompress/ncfind.py", line 24, in is_netCDF_compressed
    fh = nc.Dataset(ncfile)
  File "netCDF4/_netCDF4.pyx", line 2015, in netCDF4._netCDF4.Dataset.__init__
  File "netCDF4/_netCDF4.pyx", line 1636, in netCDF4._netCDF4._ensure_nc_success
OSError: [Errno -51] NetCDF: Unknown file format: b'wind/data_my/temp-month/transfer.bash'

ncfind.py has an `except RuntimeError` at line 28 but didn't catch this one.
diff --git a/test/test_ncfind.py b/test/test_ncfind.py
new file mode 100644
index 0000000..415dfb5
--- /dev/null
+++ b/test/test_ncfind.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+
+"""
+Copyright 2015 ARC Centre of Excellence for Climate Systems Science
+author: Aidan Heerdegen <aidan.heerdegen@anu.edu.au>
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+    http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import pytest
+import imp
+from netCDF4 import Dataset
+from numpy import array, arange, dtype
+from numpy.testing import assert_array_equal, assert_array_almost_equal
+import os
+from utils import make_simple_netcdf_file, remove_ncfiles
+from nccompress import ncfind, nc2nc
+
+from glob import glob
+
+verbose = True
+
+ncfiles =['simple_xy.nc']
+
+def setup_module(module):
+    if verbose: print ("setup_module      module:%s" % module.__name__)
+    remove_ncfiles(verbose)
+    make_simple_netcdf_file(ncfiles)
+    # Compress the file we just made
+    nc2nc.nc2nc(ncfiles[0], ncfiles[0]+'2nc.nc',clobber=True)
+ 
+def teardown_module(module):
+    if verbose: print ("teardown_module   module:%s" % module.__name__)
+    remove_ncfiles(verbose)
+
+def test_find():
+
+    arguments = ['-u']
+    arguments.extend(ncfiles)
+    args = ncfind.parse_args(arguments)
+    found = ncfind.find_files(args)
+    found = [os.path.normpath(file) for file in found]
+    assert(len(ncfiles) == len(found))
+    assert(found == ncfiles)
+
+    arguments = ['-c']
+    arguments.extend(ncfiles)
+    args = ncfind.parse_args(arguments)
+    found = ncfind.find_files(args)
+    assert(found == [])
+
+    files = ncfiles + [ncfiles[0]+'2nc.nc']
+
+    arguments = ['-u']
+    arguments.extend(files)
+    args = ncfind.parse_args(arguments)
+    found = ncfind.find_files(args)
+    found = [os.path.normpath(file) for file in found]
+    assert(1 == len(found))
+    assert(found == files[0:1])
+
+    arguments = ['-c']
+    arguments.extend(files)
+    args = ncfind.parse_args(arguments)
+    found = ncfind.find_files(args)
+    found = [os.path.normpath(file) for file in found]
+    assert(1 == len(found))
+    assert(found == files[1:])
+
+
diff --git a/test/utils.py b/test/utils.py
index d8405cf..e0bc036 100644
--- a/test/utils.py
+++ b/test/utils.py
@@ -50,7 +50,7 @@ def make_simple_netcdf_file(ncfiles):
     # create the variable (4 byte integer in this case)
     # first argument is name of variable, second is datatype, third is
     # a tuple with the names of dimensions.
-    data = ncfile.createVariable('data',np.dtype('float32').char,('y','x'))
+    data = ncfile.createVariable('data',np.dtype('float32').char,('x','y'))
     data.setncattr("Unhidden","test")
     # write data to variable.
     data[:] = data_out

conda/dev-environment.yml
pip install -e .[dev]
parse_log_pytest
environment.yml
pytest
apt-get update apt-get install -y gcc
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
attrs==22.2.0
Babel==2.11.0
certifi==2021.5.30
cftime @ file:///home/conda/feedstock_root/build_artifacts/cftime_1632539733990/work
charset-normalizer==2.0.12
commonmark==0.9.1
docutils==0.18.1
idna==3.10
imagesize==1.4.1
importlib-metadata==4.8.3
iniconfig==1.1.1
Jinja2==3.0.3
MarkupSafe==2.0.1
-e git+https://github.com/coecms/nccompress.git@b2546051531172beeff6f193d24463a6caeff292#egg=nccompress
netCDF4 @ file:///home/conda/feedstock_root/build_artifacts/netcdf4_1633096406418/work
numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1626681920064/work
packaging==21.3
pbr @ file:///home/conda/feedstock_root/build_artifacts/pbr_1724777609752/work
pluggy==1.0.0
py==1.11.0
Pygments==2.14.0
pyparsing==3.1.4
pytest==7.0.1
pytz==2025.2
recommonmark==0.7.1
requests==2.27.1
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
snowballstemmer==2.2.0
Sphinx==5.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
zipp==3.6.0

name: nccompress
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
  - bzip2=1.0.8=h7f98852_4
  - c-ares=1.19.1=h5eee18b_0
  - ca-certificates=2025.2.25=h06a4308_0
  - cdo=2.0.3=he19d259_1
  - certifi=2021.5.30=py36h06a4308_0
  - cftime=1.5.1=py36he33b4a0_0
  - curl=8.2.1=h37d81fd_0
  - eccodes=2.26.0=hc08acdf_0
  - expat=2.4.8=h27087fc_0
  - fftw=3.3.10=nompi_h77c792f_102
  - freeglut=3.2.2=h9c3ff4c_1
  - hdf4=4.2.15=h10796ff_3
  - hdf5=1.12.1=nompi_h2750804_100
  - icu=68.2=h9c3ff4c_0
  - jasper=2.0.33=ha77e612_0
  - jbig=2.1=h7f98852_2003
  - jpeg=9e=h166bdaf_1
  - krb5=1.20.1=h568e23c_1
  - ld_impl_linux-64=2.40=h12ee557_0
  - lerc=2.2.1=h9c3ff4c_0
  - libaec=1.0.6=h9c3ff4c_0
  - libblas=3.9.0=16_linux64_openblas
  - libcblas=3.9.0=16_linux64_openblas
  - libcurl=8.2.1=h91b91d3_0
  - libdeflate=1.7=h7f98852_5
  - libedit=3.1.20230828=h5eee18b_0
  - libev=4.33=h516909a_1
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgfortran-ng=13.2.0=h69a702a_0
  - libgfortran5=13.2.0=ha4646dd_0
  - libglu=9.0.0=he1b5a44_1001
  - libgomp=11.2.0=h1234567_1
  - libiconv=1.17=h166bdaf_0
  - liblapack=3.9.0=16_linux64_openblas
  - libnetcdf=4.8.1=nompi_hb3fd0d9_101
  - libnghttp2=1.52.0=ha637b67_1
  - libopenblas=0.3.21=h043d6bf_0
  - libpng=1.6.37=h21135ba_2
  - libssh2=1.10.0=ha56f1ee_2
  - libstdcxx-ng=11.2.0=h1234567_1
  - libtiff=4.3.0=hf544144_1
  - libwebp-base=1.2.2=h7f98852_1
  - libxcb=1.13=h7f98852_1004
  - libxml2=2.9.12=h72842e0_0
  - libzip=1.8.0=h4de3113_1
  - lz4-c=1.9.3=h9c3ff4c_1
  - ncurses=6.4=h6a678d5_0
  - netcdf4=1.5.7=nompi_py36h775750b_103
  - numpy=1.19.5=py36hfc0c790_2
  - openssl=1.1.1w=h7f8727e_0
  - ossuuid=1.6.2=hf484d3e_1000
  - pbr=6.1.0=pyhd8ed1ab_0
  - pip=21.2.2=py36h06a4308_0
  - proj=8.2.1=h277dcde_0
  - pthread-stubs=0.4=h36c2ea0_1001
  - python=3.6.13=h12debd9_1
  - python_abi=3.6=2_cp36m
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - six=1.16.0=pyh6c4a22f_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - udunits2=2.2.28=hc3e0081_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xorg-fixesproto=5.0=h7f98852_1002
  - xorg-inputproto=2.3.2=h7f98852_1002
  - xorg-kbproto=1.0.7=h7f98852_1002
  - xorg-libx11=1.7.2=h7f98852_0
  - xorg-libxau=1.0.9=h7f98852_0
  - xorg-libxdmcp=1.1.3=h7f98852_0
  - xorg-libxext=1.3.4=h7f98852_1
  - xorg-libxfixes=5.0.3=h7f98852_1004
  - xorg-libxi=1.7.10=h7f98852_0
  - xorg-xextproto=7.3.0=h7f98852_1002
  - xorg-xproto=7.0.31=h7f98852_1007
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - zstd=1.5.0=ha95c52a_0
  - pip:
      - alabaster==0.7.13
      - attrs==22.2.0
      - babel==2.11.0
      - charset-normalizer==2.0.12
      - commonmark==0.9.1
      - docutils==0.18.1
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - jinja2==3.0.3
      - markupsafe==2.0.1
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytz==2025.2
      - recommonmark==0.7.1
      - requests==2.27.1
      - snowballstemmer==2.2.0
      - sphinx==5.3.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - zipp==3.6.0
prefix: /opt/conda/envs/nccompress

test/test_ncfind.py::test_find
nccompress/ncfind.py
nccompress/ncfind.py