#C4438. Clean Text File

    ID: 47976 Type: Default 1000ms 256MiB

Clean Text File

Clean Text File

You are given a text file that consists of N lines. Each line may have leading or trailing whitespace, extra spaces between words, or even be blank. Your task is to process the file and output only the cleaned, non-empty lines. Specifically, you must:

  • Remove any leading and trailing whitespace from each line.
  • Replace every sequence of one or more whitespace characters between words with a single space.
  • Discard any line that is blank (i.e. becomes empty after cleaning).

For example, given a line:

\[ \texttt{ This is a test. } \]

It should be transformed into:

\[ \texttt{This is a test.} \]</p>

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

  1. The first line contains an integer N which represents the number of lines in the file.
  2. The following N lines each contain a string corresponding to a line from the text file.

outputFormat

Output the cleaned, non-empty lines to standard output (stdout). Each cleaned line should be printed on a separate line.

## sample
5
  This is  a    sample     text.  
   Here is    another   line.   
 

  And    yet   another    one. 
This is a sample text.

Here is another line. And yet another one.

</p>