Broke out string format generation into a function and added a new test for empty lines.