The below option can be set to prevent vim from add a newline at the end of a file
:set nofixendofline
This option is useful when you edit a file under version control system or the extra new line may cause problems.
Reference:
https://stackoverflow.com/questions/1050640/how-to-stop-vim-from-adding-a-newline-at-end-of-file