You must call close() before exiting your program or essential records will not be written.