This question is a follow up and based on this question (using an altered MWE from this answer)
Situation
I am importing several parts of a file into another one (a summary-excerpt). This is done using the method described by touhami in the two linked questions.
Question
Why do the spaces behind lines go missing, if and only if there is no subsequent comment %... ? And how to fix that ?
Obviously one could not use line breaks in code. Though for readabilities sake I'd prefer to have such without the need to add %all over the place.
MWE (compare linked posts)
file.tex
\documentclass{amsart}
\usepackage{lipsum}
\newenvironment{mtexclude}{}{}
\begin{document}
First bla bla
%<*tag>
\section{Foo}
\subsection{Foo bar}
I need this % here is a space at end of line with comment afterwards
certain text \textbf{``no more space!''},
plus another one: \textbf{``without comments''}.
%
But space goes missing.
%note the space at the end of line 16 and 17 WITHOUT anything behind
\begin{mtexclude}% begin of part to skiped
\section{Baz}
\subsection{Baz bar}
no need for this
\end{mtexclude}% end
\section{End}
\subsection{End bar}
and need this \dots
\begin{mtexclude}% begin of part to skiped
%no problems here
\section{Baz 2}
\subsection{Baz bar 2}
another part to be skiped
\end{mtexclude}% end
The end
%</tag>
Last bla bla
\end{document}
newfile.tex
\documentclass{amsart}
\usepackage{lipsum}
\usepackage{catchfilebetweentags}
\newtoks\temptoken
\newbox\mtbox
\makeatletter
\newenvironment{mtexclude}{%
\setbox\mtbox\vbox\bgroup%
\def\@float##1{\def\@captype{##1}}%
\let\end@float\relax%
}{\egroup}
\makeatother
\begin{document}
\lipsum[1]
\CatchFileBetweenTags\temptoken{file}{tag}
\the\temptoken
\end{document}


"in latex input, use\`and''` – David Carlisle Feb 19 '17 at 16:45\quotes{text}, but by an oversight I have forgotten to do so here. – BadAtLaTeX Feb 19 '17 at 16:49catchfilebetweentagsabout it ? (Or is there just the email ?) – BadAtLaTeX Feb 21 '17 at 19:07\usepackage{etoolbox} \makeatletter \patchcmd{\CatchFBT@Fin@l}{\endlinechar\m@ne}{}{}{} \makeatother– touhami Feb 21 '17 at 19:32catchfilebetweentags- block)! – BadAtLaTeX Feb 21 '17 at 19:48