You can write the data using the write() method and then call the flush() method to force the os
to write to the file, finally close() method to close the file writer object, so that it can be garbage
collected.