optimize file reading in pbx_spool (bug #3927)