From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Out_File , excess line Date: Sun, 31 Jan 2016 11:25:10 +0000 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="d1f7d2633ee45ab9629ebafbf83c9647"; logging-data="4887"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gdbpeOfG8g8xMcG01M1URa6r+001poDA=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:TRx1JIJCrFXIb/DNpAJd1zhn6yo= sha1:fdkyGoNlrSJ/8GFVnbDdW6vfZQU= Xref: news.eternal-september.org comp.lang.ada:29301 Date: 2016-01-31T11:25:10+00:00 List-Id: comicfanzine@gmail.com writes: > Procedure Close [...] outputs a file terminator . > > Terminate_Line call new_line . > > So, for removing the excess line , i must eliminate this Terminate_Line ? > > If its correct , i understand better . > > How to proceed in this case ? > > Is there another way ? The standard solution to copying a file would be with Ada.Text_IO; use Ada.Text_IO; procedure Fanzine is Input_File : File_Type; Output_File : File_Type; Lines : Natural := 0; begin Open (Input_File, Name => "fanzine.adb", Mode => In_File); begin Open (Output_File, Name => "fanzine.adb.copy", Mode => Out_File); exception when Name_Error => Create (Output_File, Name => "fanzine.adb.copy"); end; begin loop declare L : constant String := Get_Line (Input_File); -- raises End_Error if no more lines begin Lines := Lines + 1; Put_Line (Output_File, L); end; end loop; exception when End_Error => null; -- exits the loop end; Close (Input_File); Close (Output_File); Put_Line ("there were" & Integer'Image (Lines) & " lines"); end Fanzine; which will only introduce an extra NL if you have an input file whose last line isn't terminated with NL. It's arguable that such a file isn't a "proper" text file anyway. Neither Emacs nor vi will produce such a file unless it's actually empty (Mac Textedit will, though). What is your reason for worrying about this?