Got the text file to open with (default) text-editor when using 'open' command. Re-factored code.