added a try-final block to clean up temporary files