Create the log file only if it is necessary

Closes #17
Add test checking that empty log is not created

Related #17