factored out file manipulation code into file_helpers.py