The gap between what the government borrows and what it spends narrowed amid less spending and higher tax receipts.