Flushes all remaining data to the file, closes all buffers and files, and returns the file name.
Returns the file name if successful, null if there was an error