Restore newline character at end of file.
Replace some closures with callbacks.