The default directory is usually different in both environments, within CB the directory is "." (where the CBP file resides) and in a terminal it is where you set it (usually the executable directory). So, depending where the txt file is, the executabe finds it or not.
To correct this in Project -> Properties -> Build targets the output filename dir and the execution working dir should be the same.