The system command will create a new process and return immediately while the process continues to run. Try using backticks to execute your external application. This waits for the spawned process to finish and can be used to slurp all of the data that the process wrote to STDOUT.
E.g.
my $data_file = "file.txt";
my $ret=`encrypt.exe $data_file`;