Split rake tasks into separate file so they can be tested. Fixed issue with write_to_file method.