Handle restart on download.
Clean up comments. Move file:close() to terminate and handle case when file is not open.
Fix compilation error.
Add in header for copyright, etc...