So i am reading a number from a file and i'd like to increase it and write it back to the file each time i compile the .tex-file. The problem is that the number is not increased by +1 as i scripted it, instead it is raised by 4 when i'm reading the file. E.g. file contains 1, reading the file and making an output gives 5 (i have no clue why?), adding 1 and writing back works fine. The file contains 6, reading the file again gives 10. Why is reading a number from a file increasing it by 4?
\documentclass{article}
\usepackage[nomessages]{fp}
\begin{document}
\def\chopline#1\\{
\def\Build{#1}
}
%---read file--------------
\newread\quelle
\openin\quelle=number.dat
\read\quelle to \zeile
\expandafter\chopline\zeile\\
read: \Build
\closein\quelle
%--EOF-----------------------------------
%--increase-----------------------
\FPeval{\build}{clip(\Build + 1)}
new number: \build
%--EOI---------------------
%--write file-----------
\newwrite\outfile
\immediate\openout\outfile=number.dat % open file
\immediate\write\outfile{\build}
\immediate\closeout\outfile % close file
%--EOF------------------------------------
\end{document}
File number.dat must exist and has to contain 1 to work properly otherwise u have to enter \zeile=1.
Thank u in advance!