Just to make it clear the command should work as follows: if the command is called with only 1 argument (a filepath) then the command should print the table of contents however when some 'table of contents' data file is given as 'INFILE' as follows pdftocio [options] in.pdf < toc then the command should add the TOC to the pdf file. So what seems to happen is that, even when INFILE in `call-process` is nil, still python determines that some (empty) `TOC` file is given as input.