Added filename check of the function: write_to_file.

The logger will log no filename as an error.