Add fclose to close file
Remove double-processing of closeChannel