x: only check for newline at EOF if file isn't empty
x: only check for newline at EOF if file isn't empty

Closes: #6063

libra/libra,libra/libra,aptos-labs/aptos-core,libra/libra,aptos-labs/aptos-core,aptos-labs/aptos-core,aptos-labs/aptos-core,aptos-labs/aptos-core,libra/libra,aptos-labs/aptos-core,libra/libra,aptos-labs/aptos-core