Added detection for creating a file name and logging what the error is. Added functionality to write to a file and helper functions to make it easier. Added shell function to write and added console output for successful or unsuccessful.