line ending issue? added more logging and possible correction