Clean up return codes
Fix missing fclose