[SP] Fix a file close that happened after an error.  Fixed a couple of missing file close calls in case of file being too large for buffer.