Created a function to get output .txt filename and refactored the name of the corresponding .json functio