Refactoring to merge sending first line and headers