This is not a file, but the contents of the returned file. Therefore, the file does not close. Try changing the variable name to Data or similarly as in the code below:
{ok, Data} = file:read_file("maillog.sample"),
Then the data will contain the contents of the file "maillog.sample". Function file: read_file / 1 will open, read and close the file for you, all in one go.
Koistinen
source share