add output redirection to command based on chaptername and line number