Add test case which verifies the occurrence of #7409.
Make sure there's a line break before writing new key. Fixes #7409.
Remove any trailing white space.