filehandles do not have a close() method.  changed to os.close(<filehandle>)